Assuming you are opening the pipe for write-only, you need to specify O_NONBLOCK on the file handle when you open it, see
. The run-time errno should be set to ENXIO if no process has the pipe open for reading. This is accessable through
might also be useful.
Alternatively use non-blocking sockets or message queues.