Re: shm_open and mmap: Invalid argument? [SOLVED]
Re: shm_open and mmap: Invalid argument? [SOLVED]
- Subject: Re: shm_open and mmap: Invalid argument? [SOLVED]
- From: Tim Hewett <email@hidden>
- Date: Mon, 21 Feb 2005 18:48:20 +0000
Hi,
Following up the thread about a subprocess not being able to mmap
a Posix shared memory file descriptor (errno == EINVAL) mentioned
last time, this was not caused by the descriptor being inherited
over a call to execve() but by mmap-ing an unlinked shared memory
descriptor. The descriptor was still open but the name had been
unlinked at the time of the mmap in the subprocess.
With normal files you can open the file, unlink it (while keeping
it open, so it still exists just not in any name space and will be
deleted when closed), and then do anything you like to it
including mmap it.
You can't do this with shared memory file descriptors, at least not
on 10.3.8, if you unlink it you can't subsequently mmap it or else you
get EINVAL. This is must be a bug...? It would be nice to see if my
Linux box does the same thing but it looks like the system hasn't
been built to support Posix. The man pages are there though as
are the library symbols, but a call to shm_open returns "Function
not supported".
Anyway the bottom line is that you can inherit an open shared
memory descriptor over fork/exec and still mmap it in the subprocess
without having to call shm_open again. Just don't shm_unlink it
first!
Tim.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden