Reputation: 141
A simple question. If I have 2 programs that needs to access 1 named pipe. If one uses open() function for reading on one end with O_RDONLY
flag, would the other end be able to open the file as O_WRONLY
and be able to write to it? Would the other program get the written data?
Upvotes: 0
Views: 229
Reputation: 58
You can do that.
if you use O_RDWR
to open the pipe, it will not block.
if you use O_RDONLY
to open the pipe, it will block until the writer opens the pipe, unless you used O_NONBLOCK
to make sure to open the pipe successfully.
if you use O_WRONLY
to open the pipe, it will block until the reader opens the pipe, but if you also use O_NONBLOCK
, the open()
will fail.
Upvotes: 1