Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hand controlling TTY to child, if we have one #122

Merged
merged 2 commits into from
Oct 10, 2016

Conversation

chriskuehl
Copy link
Contributor

Fixes #51

This uses the patch from @Ehlers almost verbatim, plus adds a test.

The new behavior is that dumb-init will hand the controlling TTY to its child, if it has one. This fixes the fairly common case where running docker run -ti <image> dumb-init bash produces:

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

With this change, you get job control in the shell (and no warnings printed). The test checks exactly this (outside of Docker, though).

@ghost
Copy link

ghost commented Oct 10, 2016

I'd like to propose some changes to the ioctl in my patch:

The ioctl are using not the correct arguments, see http://man7.org/linux/man-pages/man4/tty_ioctl.4.html, TIOCSCTTY has an int argument and TIOCNOTTY has none. Furthermore I suggest using STDIN_FILENO instead of 0 for the file descriptor.

So I propose to change ioctl(0, TIOCNOTTY, NULL) to ioctl(STDIN_FILENO, TIOCNOTTY) and ioctl(0, TIOCSCTTY, NULL) to ioctl(STDIN_FILENO, TIOCSCTTY, 0).

@chriskuehl
Copy link
Contributor Author

@Ehlers thanks for taking a look! I added a commit with those changes. Does it look right now?

@ghost
Copy link

ghost commented Oct 10, 2016

Look good for me (and for circleci :-)

@chriskuehl chriskuehl merged commit b66cbb0 into Yelp:master Oct 10, 2016
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.

Error: cannot set terminal process group (-1): Inappropriate ioctl for device
2 participants