By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,820 Members | 1,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,820 IT Pros & Developers. It's quick & easy.

Problems getting open() to fail!

P: n/a
Hello,

I'm trying to get open() to return immediately (preferrably with a
predictable error code, e.g. -1) if it can't open the given file
immediately.

The file is actually a sound device, /dev/dsp, on a linux box. At the
moment, if it can't open it then it just sits and waits in the
background until it can, whereas I would like it to just fail (as then
it can carry on with the other stuff without audio, or else stop
completely).

I've tried using O_NONBLOCK (on both read and write only modes) but
that seems to have no effect whatsoever. I don't know anything about
the device, whether it's FIFO etc., and have completely run out of
ideas.

Surely what I want to do must be possible - does anyone have any ideas
as to how?! (It could be a test using something else before calling
open() even).

Many thanks,

Springmaus

N.B. testing to see if the file exists doesn't help as /dev/dsp is
always there so it fails all the time - which I don't want! Also
testing whether it's in use is equally unhelpful.
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.