Skip to content

fix: remove Setsid from runWithoutReap to restore TTY#567

Merged
AkihiroSuda merged 1 commit intorootless-containers:masterfrom
fahedouch:fix-tty-setsid-regression
Apr 1, 2026
Merged

fix: remove Setsid from runWithoutReap to restore TTY#567
AkihiroSuda merged 1 commit intorootless-containers:masterfrom
fahedouch:fix-tty-setsid-regression

Conversation

@fahedouch
Copy link
Copy Markdown
Contributor

@fahedouch fahedouch commented Mar 31, 2026

Commit 2ca0537 added Setsid=true in runWithoutReap() as part of the Pdeathsig implementation, but Pdeathsig doesn't actually need it. Setsid creates a new session which detaches the child from the terminal, so bash loses its TTY and prints:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

This PR simply removes Setsid=true from the non-reaping path. The reaping path (runAndReap) keeps it because it needs session isolation to reap zombie processes.

Fixes #557

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash the commits

}

func runWithoutReap(cmd *exec.Cmd) error {
cmd.SysProcAttr.Setsid = true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to have a test?

@AkihiroSuda AkihiroSuda added this to the v3.0.0 milestone Mar 31, 2026
@fahedouch fahedouch force-pushed the fix-tty-setsid-regression branch 4 times, most recently from fa99e86 to e5b7c66 Compare March 31, 2026 22:12
Commit 2ca0537 introduced Setsid=true in runWithoutReap(), which
creates a new session for the child process and detaches it from the
controlling terminal. This causes bash to fail with:

  bash: cannot set terminal process group (-1): Inappropriate ioctl for device
  bash: no job control in this shell

Setsid is only needed in runAndReap() where rootlesskit acts as init
and needs session isolation for zombie reaping via Wait4(-1, ...).
In the non-reaping path, the child should inherit the parent session
to retain access to the TTY.

Pdeathsig (PR_SET_PDEATHSIG) does not require Setsid.

An integration test for runWithoutReap is added to prevent
regressions.

Fixes rootless-containers#557

Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
@fahedouch fahedouch force-pushed the fix-tty-setsid-regression branch from 9733b6e to 8b6a623 Compare March 31, 2026 22:56
Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit ad75008 into rootless-containers:master Apr 1, 2026
27 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v3.0.0-alpha.0 regression: bash: cannot set terminal process group (-1): Inappropriate ioctl for devic

2 participants