Stop the Stop button from killing the web server

UI-launched jobs inherited php-fpm's process group, so stopping one that was
actually running group-killed the WebGUI; setsid makes the job its own group
leader and stop.php now refuses to signal any group it does not lead.
This commit is contained in:
Gmer4Lfe
2026-08-08 11:09:08 -04:00
parent 228aae31c9
commit 2ab7d3d98a
3 changed files with 44 additions and 12 deletions
+5 -1
View File
@@ -121,6 +121,10 @@ $extraStr = '';
foreach (preg_split('/\s+/', $extra_args, -1, PREG_SPLIT_NO_EMPTY) as $tok) {
$extraStr .= ' ' . escapeshellarg($tok);
}
exec('nohup bash ' . escapeshellarg($runner) . ' ' . escapeshellarg($id) . ' ' . escapeshellarg($script) . ($flags ? " $flags" : '') . ' --manual' . $locArg . $extraStr . ' >> ' . escapeshellarg($logFile) . ' 2>&1 </dev/null &');
// setsid, not just nohup: the job must lead its own process group so api/stop.php can signal the
// whole tree without touching anything else. nohup only ignores SIGHUP, and `&` under the
// non-interactive `sh -c` that exec() uses has job control off, so without this the job inherits
// the php-fpm worker's process group — and stopping it group-killed the web server.
exec('setsid nohup bash ' . escapeshellarg($runner) . ' ' . escapeshellarg($id) . ' ' . escapeshellarg($script) . ($flags ? " $flags" : '') . ' --manual' . $locArg . $extraStr . ' >> ' . escapeshellarg($logFile) . ' 2>&1 </dev/null &');
echo json_encode(['ok' => true]);