-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
Background: our Go code is built with -buildmode=c-archive
and linked into a macOS app built by xcode. We are not installing any signal handlers, but it is possible some Apple library is doing so behind our backs. We are using the os/exec
package to periodically execute netstat -an
.
Occasionally, the os/exec.Cmd.Wait
method is returning EINTR
. This EINTR
comes directly from os.Process.Wait. Unfortunately the os/exec package does not expect EINTR, and so it treats it as if the fork process has exited and cleans up its state, so that Cmd.Wait cannot be called again.
The darwin man pages wait(2)
and sigaction(2)
suggest this should only happen if a signal handler does not have the SA_RESTART flag set. I have not yet determined if Apple is setting another handler for us, or if this is something unusual like Issue #11180.
Even if this is a core Apple library setting a handler (we use no third-party code), it may be worth handling EINTR for darwin in os.Process.Wait
, to make the object useful in Go code linked with -buildmode=c-archive
.