Side effects of open system call
Hi, In ioctl man page, mentioned that 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. Does anybody know what are side effects of open in general ? Thanks, Rahul ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Side effects of open system call
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'. Most people would call that an unwanted side effect. :) pgpyR6hQDTyjH.pgp Description: PGP signature ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Side effects of open system call
On Thu, Feb 20, 2014 at 9:06 PM, valdis.kletni...@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@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Side effects of open system call
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 rpal...@gmail.com wrote: On Thu, Feb 20, 2014 at 9:06 PM, valdis.kletni...@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@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 ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies