O_NONBLOCK
If possible, the file will be opened in nonblocking mode. Neither the open() call,
nor any other operation will cause the process to block (sleep) on the I/O. This
behaviour may be defined only for FIFOs.
Sometimes, programmers do not want a call to read() to block when there is no data
available. Instead, they prefer that the call return immediately, indicating that no data
is available. This is called nonblocking I/O; it allows applications to perform I/O, potentially
on multiple files, without ever blocking, and thus missing data available in
another file.
Consequently, an additional errno value is worth checking: EAGAIN.
- from - Linux system programming second edition R Love.
If possible, the file will be opened in nonblocking mode. Neither the open() call,
nor any other operation will cause the process to block (sleep) on the I/O. This
behaviour may be defined only for FIFOs.
Sometimes, programmers do not want a call to read() to block when there is no data
available. Instead, they prefer that the call return immediately, indicating that no data
is available. This is called nonblocking I/O; it allows applications to perform I/O, potentially
on multiple files, without ever blocking, and thus missing data available in
another file.
Consequently, an additional errno value is worth checking: EAGAIN.
- from - Linux system programming second edition R Love.
so yes.
On Fri, Feb 21, 2014 at 9:52 AM, Rahul Bedarkar <rpal143@xxxxxxxxx> wrote:
Thanks, Does this mean that if I open a device file with O_NONBLOCK flagOn Thu, Feb 20, 2014 at 9:06 PM, <Valdis.Kletnieks@xxxxxx> wrote:
> On Thu, 20 Feb 2014 20:36:44 +0530, Rahul Bedarkar said:
>
>> "Often the open(2) call has unwanted side effects, that can be avoided
>> under Linux by giving it the O_NONBLOCK flag."
>>
>> I have seen open man page but can't find what are side effects of open.
>
> Well, for starters, the open() call can block while trying to open a hardware
> device that isnt ready, thus hanging the entire process. For added joy,
> remember that signals are delivered when a process inside a syscall finally
> returns to userspace - which means that your hung process may be unkillable
> even by 'kill -9'.
>
and if device is not ready by that time open system call will return
immediately and fail?
_______________________________________________
> Most people would call that an unwanted side effect. :)
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--
easy is right
begin right and you're easy
continue easy and you're right
the right way to go easy is to forget the right way
and forget that the going is easy....
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies