Reputation: 466
What I mean to ask is: Let's say a process calls poll(fd array), waiting for any of those file descriptors to be written to. And let's say another process writes to one of those file descriptors. Can I be sure that the second process will finish writing before poll() returns?
Upvotes: 0
Views: 162
Reputation: 283893
It depends on the type of the underlying pseudofile.
For byte-oriented (character devices), all you know when poll
returns is that there is some data to read, not that any particular boundary has been reached. In particular, it doesn't wait for the "sender process finished writing" boundary, or even the "all data from a single write()
call" boundary. Boundaries are not preserved.
For message queues (in Win32 this is a pipe with PIPE_TYPE_MESSAGE
) and datagram sockets, then message boundaries are preserved and the entire argument of a write()
(or send
or sendto
) call will appear atomically at the destination, poll()
won't trigger until the whole datagram is transferred.
Upvotes: 2