Side effects of open system call

parinay parinay at gmail.com
Thu Feb 20 23:43:46 EST 2014


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.
so yes.



HTH


On Fri, Feb 21, 2014 at 9:52 AM, Rahul Bedarkar <rpal143 at gmail.com> wrote:

> On Thu, Feb 20, 2014 at 9:06 PM,  <Valdis.Kletnieks at vt.edu> 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'.
> >
>
> Thanks, Does this mean that if I open a device file with O_NONBLOCK flag
> 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 at kernelnewbies.org
> 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....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140221/dddc82e8/attachment.html 


More information about the Kernelnewbies mailing list