Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
syscall: ExtraFiles FD used to set controlling TTY instead of SysProcAttr.Ctty field #29458
What did you do?
In some corner cases,
This occurs when the FD number of
This happens because the dup2 loop of forkAndExecInChild1 runs before the ioctl calls to set the Ctty. When making the ioctl calls, it's still is using the
The following reproducing code (compiled with CGo enabled, on Linux w/ glibc) first creates a child process where the bug doesn't occur and then one where the bug does occur. When the bug occurs,
This might be in something of a grey area as to whether it's a bug or expected behavior, but I'd consider this a bug because:
What did you expect to see?
I expected both cases in the reproducing code to work, making the ioctl call to set the ctty using the
What did you see instead?
In the case where the bug occurs, this is the filtered strace output:
Even though the child process does call the ioctl on FD 11 at the end, 11 was previously overwritten by a dup2 call (from 13, which itself was dup2'd from 10, which is a FD configured in
So the end effect is that the parent's FD 10 from
Does this issue reproduce with the latest release (go1.11.4)?