linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* trouble with open()
@ 1999-10-03 16:24 hollis
  1999-10-03 16:46 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: hollis @ 1999-10-03 16:24 UTC (permalink / raw)
  To: linuxppc-dev


Ok, maybe I'm just being really stupid, but the following code isn't
working for me.

I'm trying to open /dev/dsp. The file descriptor returned by open is 0,
which is supposed to be stdin, right? Anyways, a subsequent call to
ioctl doesn't like fd 0 either.

[dev->path = "/dev/dsp"]

    printf("attmpting to open %s\n", dev->path);
    if (dev->dev_fd = open(dev->path, O_RDWR) < 0) {
        perror(dev->path);
        fprintf(stderr, "Couldn't open audio device %s!\n", dev->path);
        return -1;
    }
    printf("dev_fd = %i\n", dev->dev_fd);

When I run this code, my output is:
attempting to open /dev/dsp
dev_fd = 0

The permissions are set fine, and I get the same problem with
/dev/audio.

What am I doing wrong? I ask because I'm a little frustrated at this
point.

-Hollis

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: trouble with open()
  1999-10-03 16:24 trouble with open() hollis
@ 1999-10-03 16:46 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 1999-10-03 16:46 UTC (permalink / raw)
  To: linuxppc-dev


On Sun, Oct 03, 1999 at 12:24:54PM -0400, hollis@andrew.cmu.edu wrote:
> 
> Ok, maybe I'm just being really stupid, but the following code isn't
> working for me.
> 
> I'm trying to open /dev/dsp. The file descriptor returned by open is 0,
> which is supposed to be stdin, right? Anyways, a subsequent call to
> ioctl doesn't like fd 0 either.
> 
> [dev->path = "/dev/dsp"]
> 
>     printf("attmpting to open %s\n", dev->path);
>     if (dev->dev_fd = open(dev->path, O_RDWR) < 0) {
>         perror(dev->path);
>         fprintf(stderr, "Couldn't open audio device %s!\n", dev->path);
>         return -1;
>     }
>     printf("dev_fd = %i\n", dev->dev_fd);

Nope, not trouble with open(), trouble with if.

Take another good look at your if clause; you need another set
of parentheses around (dev->dev_fd = open(dev->path, O_RDWR). = is
lower precedence than <.


> 
> When I run this code, my output is:
> attempting to open /dev/dsp
> dev_fd = 0
> 
> The permissions are set fine, and I get the same problem with
> /dev/audio.
> 
> What am I doing wrong? I ask because I'm a little frustrated at this
> point.
> 
> -Hollis
> 
> 


Dan

/--------------------------------\  /--------------------------------\
|       Daniel Jacobowitz        |__|        SCS Class of 2002       |
|   Debian GNU/Linux Developer    __    Carnegie Mellon University   |
|         dan@debian.org         |  |       dmj+@andrew.cmu.edu      |
\--------------------------------/  \--------------------------------/

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-10-03 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-10-03 16:24 trouble with open() hollis
1999-10-03 16:46 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).