So here's a fun problem. Given two processes communicating via a pipe, how can you tell if the pipe is full?
At least on Linux it appears that the best (and what looks like the only) way of doing so querying the number of unread bytes using the FIONREAD ioctl. If you get a value like 65536 (the default pipe capacity since 2.6.11) then it's full.
What if it's not a named pipe? Well then you can use /proc/${pid}/fd/${pipe_fd} to gain access to the pipe between the two processes.
At least on Linux it appears that the best (and what looks like the only) way of doing so querying the number of unread bytes using the FIONREAD ioctl. If you get a value like 65536 (the default pipe capacity since 2.6.11) then it's full.
What if it's not a named pipe? Well then you can use /proc/${pid}/fd/${pipe_fd} to gain access to the pipe between the two processes.