crashed service does not auto-restart if it forked children

reported by @stacyharper, this is actually the problem that I was trying to debug in #37. See my comments in that issue for more details.

go's os/exec doesn't consider the parent process to done (even if it crashes) since the stdout/stderr pipes are still open by any child process(es) it forks. One way to solve this is to send an os.File directly to exec to have service output written to separate files directly, instead of sending a pipe.

this can be reproduced by using the script from #37, and killing the parent process (the child should stay alive). superd will consider it still running.

Assigned to
3 months ago
3 months ago

~craftyguy 3 months ago

I'll probably have to ditch go-cmd (or make a large patch for it...) to support calling Go's os/exec with an os.File, since that module only gives os/exec an io.Writer thing, which causes this whole issue.

~craftyguy 3 months ago

I think this problem is due to this behavior in the Go runtime: https://go-review.googlesource.com/c/go/+/401835/11/src/os/exec/exec.go#247

// If WaitDelay is zero (the default), I/O pipes will be read until EOF,
// which might not occur until orphaned subprocesses of the command have
// also closed their descriptors for the pipes.

~craftyguy REPORTED FIXED 3 months ago

fixed by a8136c3c

Register here or Log in to comment, or comment via email.