LINUX shm_open::Bad file descriptor / (SGI Runs Well)
From: Christopher M. Lusardi (clusardi2k_at_aol.com)
Date: 11/17/04
- Next message: David Anderson: "Re: LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Previous message: Dr Balwinder Singh Dheeman: "Re: Play mp3 on a headless box, control headless box with a web browser"
- Next in thread: David Anderson: "Re: LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Reply: David Anderson: "Re: LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 Nov 2004 12:45:48 -0800
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!
Note: The program compiles on Linux with the -lrt option.
Thank you,
Christopher Lusardi
------------------------- Routine ---------------------------
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int initialize ()
{
int my_size;
void *my_ptr;
int my_memory;
my_size = 0x100000; /* number of bytes */
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! */
if ( my_memory == -1 )
{
perror (shm_open:");
exit (1);
}
ptr = (void *) mmap (NULL,my_size,(PROT_READ | PROT_WRITE),
(MAP_SHARED),my_memory,0); /* memory */
if ( ptr == MAP_FAILED )
{
perror ("mmap");
exit (1);
}
if ( close (shmd) )
{
perror ("close");
exit (1);
}
return (ptr);
}
/********************* Caller Routine **********************/
int main ()
{
(void) initialize (); /* check stubbed routine */
}
- Next message: David Anderson: "Re: LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Previous message: Dr Balwinder Singh Dheeman: "Re: Play mp3 on a headless box, control headless box with a web browser"
- Next in thread: David Anderson: "Re: LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Reply: David Anderson: "Re: LINUX shm_open::Bad file descriptor / (SGI Runs Well)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|