fix(sched): kill running actions when meowc is interrupted
Ctrl-C killed meowc and left every compiler it had spawned running, still holding CPU and still about to write into the build directory. There were no signal handlers at all. SIGINT and SIGTERM now cancel the same way a build failure does, and the run returns cleanly so the cache is still written and the exit status is 130. A second signal falls through to the default handler, so an unresponsive child cannot trap the user. Signalling a single pid was not enough: a compiler driver spawns its own children, and those were reparented to init and survived. Each action is now placed in its own process group with setsid, and cancellation signals the group, which also makes the existing failure path reach grandchildren. Unix.wait is retried on EINTR so a signal arriving mid-wait is not fatal.
This commit is contained in:
2 files changed
+52
-10
No files matched your search
+6
-2
@@ -205,7 +205,7 @@ let execute p ~names =
|
||||
end)
|
||||
order;
|
||||
Printf.printf "\n %s\n" (Style.dim (Printf.sprintf "%d actions, nothing run" !n));
|
||||
(b, { Sched.built = 0; cached = 0; failed = 0; aborted = 0 })
|
||||
(b, { Sched.built = 0; cached = 0; failed = 0; aborted = 0; interrupted = false })
|
||||
end
|
||||
else begin
|
||||
let cache = Cache.load (Filename.concat p.tc.builddir ".meowc-cache") in
|
||||
@@ -223,7 +223,10 @@ let execute p ~names =
|
||||
let summarise (r : Sched.result) elapsed =
|
||||
if not fl.quiet && not fl.dry then begin
|
||||
let text =
|
||||
if r.failed > 0 then
|
||||
if r.interrupted then
|
||||
Style.yellow "interrupted"
|
||||
^ (if r.aborted > 0 then Style.dim (Printf.sprintf ", %d cancelled" r.aborted) else "")
|
||||
else if r.failed > 0 then
|
||||
Style.red (Style.plural r.failed "action" ^ " failed")
|
||||
^ (if r.aborted > 0 then Style.dim (Printf.sprintf ", %d cancelled" r.aborted) else "")
|
||||
else if r.built = 0 then Style.dim "nothing to do"
|
||||
@@ -233,6 +236,7 @@ let summarise (r : Sched.result) elapsed =
|
||||
(if r.built + r.failed + r.aborted = 0 then "" else "\n")
|
||||
(Style.pad 48 text) (Style.dim (duration elapsed))
|
||||
end;
|
||||
if r.interrupted then exit 130;
|
||||
if r.failed > 0 then exit 1
|
||||
|
||||
let cmd_build names =
|
||||
|
||||
Reference in new issue
Block a user