From ed6eb46468950a0aaf9d0c88d071c95c527f3ba4 Mon Sep 17 00:00:00 2001 From: Steve Mokris Date: Wed, 6 Apr 2022 21:40:06 -0400 Subject: [PATCH] Ensure vmobj.pid is systemd-shutdown before sending SIGCHLD --- src/vm/node_modules/VM.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/vm/node_modules/VM.js b/src/vm/node_modules/VM.js index 8eeb89188..96e680716 100644 --- a/src/vm/node_modules/VM.js +++ b/src/vm/node_modules/VM.js @@ -17647,7 +17647,12 @@ function doShutdownStop(vmobj, options, callback) // its list of remaining processes. // (By default, `systemd-shutdown` waits 90 seconds // for a root cgroup SIGCHLD that is never sent.) - killSig(vmobj.pid, 'SIGCHLD'); + fs.readlink('/proc/' + vmobj.pid + '/path/a.out', + function (err, link) { + if (!err && jsprim.endsWith(link, '/systemd-shutdown')) { + killSig(vmobj.pid, 'SIGCHLD'); + } + }); if (Date.now(0) > stop_timeout) { clearInterval(ival); @@ -18235,7 +18240,12 @@ function doReboot(vmobj, options, callback) // its list of remaining processes. // (By default, `systemd-shutdown` waits 90 seconds // for a root cgroup SIGCHLD that is never sent.) - killSig(vmobj.pid, 'SIGCHLD'); + fs.readlink('/proc/' + vmobj.pid + '/path/a.out', + function (err, link) { + if (!err && jsprim.endsWith(link, '/systemd-shutdown')) { + killSig(vmobj.pid, 'SIGCHLD'); + } + }); } if (reboot_complete) { log.debug('reboot marked complete, cleaning up');