tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: open()ing a named pipe with no current readers

On Fri, Jun 15, 2018 at 01:35:17PM +0200, Edgar Fu? wrote:
 > I guess that's a rater silly/basic question, but ...
 > Is there a way to open(.. O_WRONLY ..) an existing named pipe that 
 > currently has no reader such that
 > -- the open() will neither block nor fail
 > -- subsequent write()s to that fd will
 > 	-- succeeed if someone started reading in the meantime
 > 	-- block/return EWOULDBLOCK if still no-one is reading
 > ?
 > Of course there's the work-around of lazily open()ing the fd before each
 > write() call.

Won't O_NONBLOCK cover this?

I don't think you can distinguish "buffer is full right now" from "no
reader" though.

Depending on what you're doing you might want a stream socket instead
of a pipe.

David A. Holland

Home | Main Index | Thread Index | Old Index