home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sun / hardware / 4314 < prev    next >
Encoding:
Internet Message Format  |  1992-09-09  |  1.7 KB

  1. Path: sparky!uunet!gatech!gatech!warlord!mhw
  2. From: mhw@warlord.UUCP (Michael H. Warfield)
  3. Newsgroups: comp.sys.sun.hardware
  4. Subject: Re: Using /dev/audio in applications
  5. Message-ID: <243@warlord.UUCP>
  6. Date: 9 Sep 92 21:04:26 GMT
  7. References: <1992Sep4.204344.22328@news.Hawaii.Edu>
  8. Organization: Thaumaturgy & Speculums Engineering
  9. Lines: 29
  10.  
  11. In <1992Sep4.204344.22328@news.Hawaii.Edu> denault@galileo.ifa.hawaii.edu (Tony Denault) writes:
  12. >   if( -1 == (soundfd = open("/dev/audio", O_WRONLY|O_NONBLOCK)) )
  13.  
  14. >BUT, the application will hang if some other process is using /dev/audio.
  15. >I though the O_NONBLOCK would prevent this. 
  16.  
  17.     I'm not real sure what O_NONBLOCK would do in this case but I use
  18. O_NDELAY and that works.  The man pages on /dev/audio make no reference to
  19. O_NONBLOCK but do specify O_NDELAY for controling immediate return if the
  20. device is busy.
  21.  
  22.     According to the man pages on "open", O_NONBLOCK is supposed to be
  23. equivalent to O_NDELAY.  If you look at /usr/include/sys/fcntlcom.h (included
  24. from /usr/include/sys/fcntl.h, which is included from /usr/include/fcntl.h)
  25. you will find that O_NDELAY is _FNDELAY and is non blocking I/O BSD 4.2 style.
  26. Same file says O_NONBLOCK is _FNONBLOCK and is non blocking I/O POSIX style.
  27. They are different bits in the option field.  Obviously, to /dev/audio, they
  28. are not at all equivalent.  I guess that means that the manual pages on
  29. "open" lied.  Sigh.....
  30.  
  31.     I have used O_NONBLOCK for opening named pipes when I did not want
  32. a write to a pipe to block.  In that case O_NDELAY affected the action when
  33. the pipe was opened (didn't wait for the other end to open) but O_NONBLOCK
  34. affected active writing when the pipe is full.
  35.  
  36.     Hope this helps...
  37.  
  38.     Mike Warfield
  39.     mhw@warlord.uucp
  40.