containers / containers/toolbox

podman run/exec should not ignore the SIGHUP signal

Open
#1,400 27 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
3.5k
Forks
262
Avg merge
3d 1h
Merged PRs (30d)
1

Description

Adapted from discussion at https://github.com/containers/podman/discussions/19944

`podman run` and `podman exec` do not terminate their child processes when a terminal window is closed. Normally, when that happens, the kernel sends a SIGHUP signal to the foreground process, signal which is completely ignored by `podman exec` so they never have a chance to terminate and keep running, even if their pty is no longer "visible".

## How to reproduce

* `podman run -it --rm alpine`
* Inside the container: `sleep infinity`
* Close the terminal window
* Notice how `sleep infinity` is still running

## How it works normally

* Open a host shell, run `sleep infinity`
* Close the terminal window
* Notice that `sleep infinity` has been terminated, because the SIGHUP was able to reach it. This is the correct POSIX behaviour

---

This issue affects toolbox and distrobox containers, as long running programs are never terminated when a terminal window is closed. Whether this is intended behaviour, I would suggest adding a command-line option to podman to respect and passthrough SIGHUP signals so it is able to behave like a regular shell for these use cases.

See also: https://github.com/89luca89/distrobox/issues/966

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior with `podman run -it --rm alpine` and `podman exec`, then trace how Toolbox invokes these commands and handles terminal signals. The change should define how SIGHUP is passed through or made configurable so processes in toolbox and distrobox containers terminate when their terminal closes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, linux
Domain
cli, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.