S
Springmaus
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.
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.