Why does SIGPIPE exist?

I don’t buy the previously-accepted answer. SIGPIPE is generated exactly when the write fails with EPIPE, not beforehand – in fact one safe way to avoid SIGPIPE without changing global signal dispositions is to temporarily mask it with pthread_sigmask, perform the write, then perform sigtimedwait (with zero timeout) to consume any pending SIGPIPE signal (which … Read more

Getting the highest allocated file descriptor

While portable, closing all file descriptors up to sysconf(_SC_OPEN_MAX) is not reliable, because on most systems this call returns the current file descriptor soft limit, which could have been lowered below the highest used file descriptor. Another issue is that on many systems sysconf(_SC_OPEN_MAX) may return INT_MAX, which can cause this approach to be unacceptably … Read more

System V IPC vs POSIX IPC

Both have the same basic tools — semaphores, shared memory and message queues. They offer a slightly different interface to those tools, but the basic concepts are the same. One notable difference is that POSIX offers some notification features for message queues that Sys V does not. (See mq_notify().) Sys V IPC has been around … Read more