Re: LINUX shm_open::Bad file descriptor / (SGI Runs Well)
From: David Anderson (davea_at_quasar.engr.sgi.com)
Date: 11/17/04
- Previous message: Christopher M. Lusardi: "LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- In reply to: Christopher M. Lusardi: "LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 Nov 2004 21:19:06 GMT
In article <d5cfdc47.0411171245.4525d26a@posting.google.com>,
Christopher M. Lusardi <clusardi2k@aol.com> wrote:
>Hello,
>
> Does anyone know why I get the message on the subject line when I
>execute the following code on Linux and/or how to fix it?
>
> The routine appears to run nicely on SGI!
> my_memory = shm_open ("/var/tmp/my_memory", (O_RDWR | O_CREAT),
> (S_IRWXO | S_IRWXG | S_IRWXU)); /* r/w others group users */
>
> chmod ("/var/tmp/my_memory",(S_IRWXG | S_IRWXU)); /* g/u */
>
> ftruncate (my_memory,my_size); /* Truncate CREATE file! */
the following is a mistake, and is confusing you.
> if ( my_memory == -1 )
> {
> perror (shm_open:");
> exit (1);
> }
The problem is that either the chmod or the ftruncate
could have changed errno. And likely did.
Test my_memory only *immediately* after the shm_open
if you want the perror to report anything even remotely meaningful.
And test the result codes from chmod and ftruncate (immediately
after each operation, of course)!
David Anderson
- Previous message: Christopher M. Lusardi: "LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- In reply to: Christopher M. Lusardi: "LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|