-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
child_process.exec is not abortable in Linux #37518
Comments
@MadaraUchiha Is this the same problem as reported in #37273? Lines 254 to 263 in 5c3bc21
and that's being fixed in #37325. |
Fixed in #37273 - thanks for the report :) |
Apparently not 😅 |
@RaisinTen I don't see how. In fact, the fact that @Linkgoron uses |
FTR I don't think this is limited to Linux. I've been able to reproduce this on our SmartOS CI instances while investigating nodejs/build#3154. |
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: #46276 Fixes: nodejs/build#3154 Refs: #37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: nodejs#46276 Fixes: nodejs/build#3154 Refs: nodejs#37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: #46276 Fixes: nodejs/build#3154 Refs: #37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: #46276 Fixes: nodejs/build#3154 Refs: #37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: #46276 Fixes: nodejs/build#3154 Refs: #37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: #46276 Fixes: nodejs/build#3154 Refs: #37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: nodejs/node#46276 Fixes: nodejs/build#3154 Refs: nodejs/node#37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
Extend the Linux logic to all POSIX platforms in test-child-process-exec-abortcontroller-promisified. PR-URL: nodejs/node#46276 Fixes: nodejs/build#3154 Refs: nodejs/node#37518 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Ruy Adorno <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: James M Snell <[email protected]>
As I recall My current solution is to kill the whole process group via signal?.addEventListener('abort', () => {
if (childProcess.pid !== undefined) {
process.kill(-childProcess.pid)
}
}) |
I think this issue is a case of wrong expectations. Maybe the documentation can be clarified but I don't consider it a node bug, it's just how the UNIX process model works. Either avoid I'm going to close this but if someone wants to send a documentation pull request, please do. |
What steps will reproduce the bug?
setInterval(() => {}, 10_000);
node keep-alive-test.js &
ps awwx | grep alive | grep -v grep | cat
node keep-alive-test.js
,sh -c node keep-alive.js
andnode keep-alive.js
ps awwx | grep alive | grep -v grep | cat
node keep-alive-test.js
andnode keep-alive.js
(sh was terminated).fg
-> CTRL+C, orkillall node
etc)How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior?
Expected behavior for
ac.abort()
was to abort the child process.What do you see instead?
Child process does not get aborted, only the shell does.
Additional information
Internally, the abort handler for all child_process methods use
child.kill()
to terminate the underlying process. However, it is documented that this does not work "as expected" in Linux.This makes
ac.abort()
quite useless onexec
ed children, since none of them would actually get aborted at all.This will probably happen if one uses
child_process.spawn()
to similarly spawn a shell to invoke a process, though I have not tested.The text was updated successfully, but these errors were encountered: