-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
build: Terminating a build process does not terminate child processes #18340
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
To be clear, in this case you are not worried about arbitrary sub-processes forked by CI right? Just Zig-spawned builders/tester processes that are all running Zig code (and are all written to be compatible with this goal)? (Handling the case where you want to kill child processes running arbitrary, non-Zig binaries seems much harder). In that case the open-pipe trick seems reasonable to me. You would need to repeat it from parent to child, and then from child to grand-child (I don't think the grand-child should get its grand-parent's pipe). Its not clear to me why you marked this one as "unviable". Assuming the child processes are generally of the form Yet another approach might be to just reboot the container/vm/environment hosting the CI runs once or twice a day to clean out the cruft. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Ouch, just got bit by this locally. I'm not sure why this happens yet. |
I think I figured it out: Lines 137 to 138 in b7e48c6
when the parent process terminates, this read keeps getting 0 bytes read and enters an infinite loop. --- a/lib/std/zig/Server.zig
+++ b/lib/std/zig/Server.zig
@@ -109,6 +109,7 @@ pub fn deinit(s: *Server) void {
pub fn receiveMessage(s: *Server) !InMessage.Header {
const Header = InMessage.Header;
const fifo = &s.receive_fifo;
+ var last_amt_zero = false;
while (true) {
const buf = fifo.readableSlice(0);
@@ -136,6 +137,10 @@ pub fn receiveMessage(s: *Server) !InMessage.Header {
const write_buffer = try fifo.writableWithSize(256);
const amt = try s.in.read(write_buffer);
fifo.update(amt);
+ if (amt == 0) {
+ if (last_amt_zero) return error.BrokenPipe;
+ last_amt_zero = true;
+ }
}
} thoughts? |
build.zig
:repro.zig
:Terminating the build process should not leave orphaned child processes running.
This bug has seemingly resulted, over a period from Oct 15 to Dec 21, in 56 currently active orphan processes on the
aarch64-macos
CI using up valuable cpu time and causing CI runs to slow down over time.The text was updated successfully, but these errors were encountered: