-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
timeout: subprocess is never terminated #4176
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
Comments
Nope, looks like a bug. Does it work with other times? Like, |
$ timeout 1.5 sh -c "yes | split --filter='head -c1 >/dev/null' -b 1000"
$ ps aux | grep split
coreuti+ 1916 0.0 0.0 3244 648 pts/0 S+ 07:38 0:00 grep split
$ /coreutils/target/release/timeout 1.5 sh -c "yes | split --filter='head -c1 >/dev/null' -b 1000"
$ ps aux | grep split
coreuti+ 1920 8.0 0.0 2944 1880 pts/0 S 07:38 0:00 split --filter=head -c1 >/dev/null -b 1000
coreuti+ 14847 0.0 0.0 3244 648 pts/0 S+ 07:38 0:00 grep split I don't think so. GNU timeout sends a signal to the process group if it is in the background. If I use |
Oh I see, I misinterpreted the explanation. Thanks! |
Would you mind giving me some hints so I can solve this problem? |
I was just looking through the code, but I'm not sure what's going wrong, so I don't have any hints, sorry. |
@miles170: Before GNU timeout kills the process group it blocks the signal for itself first here. It should be enough to just copy that behaviour, i.e. block the signal, before sending it to the process group, and also send SIGCONT to the child and the whole process group after that. Note, that GNU timeout doesn't check for errors of signal. We shouldn't, either. For example: The subprocess/shell might have exited just after the timeout. Sending a signal now would return ESRCH, but we should still try to kill the children. On linux,
|
If the process exits by itself right after the timeout, GNU timeout shows a different behaviour: After sending the signals, it calls Our timeout just assumes the process exited because of the timeout. We should call |
When I was working on #4073, I discovered that timeout never terminates the subprocess under the sh shell.
Is this expected behavior?
The text was updated successfully, but these errors were encountered: