Re: "broken pipe", but not when debugging...
For some reason lost in ancient Unix history, if you write to a file-descriptor that’s been closed at the other end, a SIGPIPE signal is raised. This will by default kill your process. It’s annoying behavior but it’s long been standardized so it can’t be changed. This doesn’t happen when run under the debugger because part of the debugger’s job is to catch all signals from your process, and I assume the debugger just ignores SIGPIPE. Traditionally the workaround has been to call signal() to install a process-wide no-op handler for SIGPIPE, but on Apple platforms (and others?) you can also set a flag on the file descriptor telling it not to raise the signal. I was going to write that it’s an option to setsockopt, but then I remembered you’re using a pipe not a socket. So I’m not sure what system call you’d use; ioctl maybe? —Jens
|
|