Problems getting open() to fail!

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.
 
T

tom_usenet

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.

Try comp.unix.programmer (or even somewhere specializing in sound card
programming), this group handles C++ language questions only.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top