Home > Archive > Unix Programming > September 2004 > shmget() and EINVAL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
shmget() and EINVAL
|
|
| Nithya Venkatachalam 2004-09-16, 5:01 am |
| Hi,
test_shmid = shmget(key,0,(SHM_R|SHM_W|IPC_CREAT));
If i specify like this,
And if the shared memory segment corresponding to the key specified
already exists,
Will the errno corresponding to shmget() failure be set to EINVAL
????
| |
| Michael Kerrisk 2004-09-16, 5:01 am |
| On 15 Sep 2004 23:54:09 -0700, "Nithya Venkatachalam"
<vnithya@gmail.com> wrote:
>Hi,
>
>test_shmid = shmget(key,0,(SHM_R|SHM_W|IPC_CREAT));
>If i specify like this,
>And if the shared memory segment corresponding to the key specified
>already exists,
>Will the errno corresponding to shmget() failure be set to EINVAL
>????
Did you read the man page? You need IPC_EXCL.
By the way, (size == 0) with IPC_CREAT is strange.
Cheers,
Michael
| |
| Robert Clark 2004-09-17, 4:03 am |
| Michael Kerrisk wrote:
> On 15 Sep 2004 23:54:09 -0700, "Nithya Venkatachalam"
> <vnithya@gmail.com> wrote:
>
>
> By the way, (size == 0) with IPC_CREAT is strange.
Just adding a couple of cents of my own, if you run this on a system with
the shared memory minimum size set to 1 (the usual default) or larger, this
will also fail with errno set to EINVAL.
Just ran across this kind of thing with a customer. They had their Solaris
kernel set so that the minimum shared memory size (SHMMIN) was 200 bytes.
My code tried to allocate less that that. Made for a very interesting error
to try and track down.
Which reminds me, anyone know how to figure out (at runtime) the value of
SHMMIN and SHMMAX on any of the common Unix/Linux systems? I did a bit of
googling around and found the /etc/system file on Solaris
and /proc/sys/kernel/* on Linux. Anyone know about AIX or HP-UX?
- Rob
--
(to email me, remove "warez.")
| |
| Juha Laiho 2004-09-17, 9:00 pm |
| Robert Clark <clark@warez.exiter.com> said:
>Which reminds me, anyone know how to figure out (at runtime) the value of
>SHMMIN and SHMMAX on any of the common Unix/Linux systems? I did a bit of
>googling around and found the /etc/system file on Solaris
>and /proc/sys/kernel/* on Linux. Anyone know about AIX or HP-UX?
The last I worked with HP-UX, the kernel parameters were easiest to
configure using their 'sam' configuration tool. There's also a file (in
/usr/conf/master.d, IIRC) you can change, but direct changes to the file
may be overwritten by subsequent runs of 'sam'.
For AIX, I'd see if it's doable using the 'smit' tool.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
| |
| Robert J. Clark 2004-09-18, 3:57 am |
| Juha Laiho wrote:
> Robert Clark <clark@warez.exiter.com> said:
>
> The last I worked with HP-UX, the kernel parameters were easiest to
> configure using their 'sam' configuration tool. There's also a file (in
> /usr/conf/master.d, IIRC) you can change, but direct changes to the file
> may be overwritten by subsequent runs of 'sam'.
>
> For AIX, I'd see if it's doable using the 'smit' tool.
I have to plead temporary insanity. I was using smit this morning and
never even thought to check. Thanks for the suggestions, I appreciate it.
- Rob
| |
| Jonathan Adams 2004-09-18, 8:56 am |
| Robert Clark <clark@warez.exiter.com> wrote:
> Michael Kerrisk wrote:
>
> Just ran across this kind of thing with a customer. They had their Solaris
> kernel set so that the minimum shared memory size (SHMMIN) was 200 bytes.
> My code tried to allocate less that that. Made for a very interesting error
> to try and track down.
Note that in Solaris 10, SHMMIN has been removed, partially because it
makes absolutely no sense.
> Which reminds me, anyone know how to figure out (at runtime) the value of
> SHMMIN and SHMMAX on any of the common Unix/Linux systems? I did a bit of
> googling around and found the /etc/system file on Solaris
> and /proc/sys/kernel/* on Linux. Anyone know about AIX or HP-UX?
In Solaris 10, this is different -- there's a pair of per-project RCTLS:
project.max-shm-memory maximum size (SHMMAX)
project.max-shm-ids maximum # of SysV shm ids
prctl(1) and getrctl(2) can be used to retrieve the current values of
them. (not that reading /etc/system is a particularly great way to get
them in pre-S10 days)
- jonathan
| |
| Robert Clark 2004-09-19, 3:56 am |
| Jonathan Adams wrote:
> Robert Clark <clark@warez.exiter.com> wrote:
>
> Note that in Solaris 10, SHMMIN has been removed, partially because it
> makes absolutely no sense.
Ain't that the truth. I could not get a strait answer from our customer as
to why they though they needed this.
>
>
> In Solaris 10, this is different -- there's a pair of per-project RCTLS:
>
> project.max-shm-memory maximum size (SHMMAX)
> project.max-shm-ids maximum # of SysV shm ids
>
> prctl(1) and getrctl(2) can be used to retrieve the current values of
> them.
That one goes into my tips and tricks file. Thanks.
> (not that reading /etc/system is a particularly great way to get
> them in pre-S10 days)
I'm not terribly thrilled about it either. Do you know of any other ways to
get the values for Solaris 2.6-9 ? I have a feeling that we will have to
support those for quite a while.
Thanks,
Rob
--
(to email me, remove "warez.")
| |
| Jonathan Adams 2004-09-19, 3:56 am |
| In article <1512291.XWtyWrSfCr@warez.exiter.com>,
Robert Clark <clark@warez.exiter.com> wrote:
> Jonathan Adams wrote:
>
>
> Ain't that the truth. I could not get a strait answer from our customer as
> to why they though they needed this.
They probably picked it up from some website.
> That one goes into my tips and tricks file. Thanks.
>
>
> I'm not terribly thrilled about it either. Do you know of any other ways to
> get the values for Solaris 2.6-9 ? I have a feeling that we will have to
> support those for quite a while.
I believe many people parse the output of /usr/sbin/sysdef -- this is
better than reading /etc/system (it's at least got the current numbers,
if the modules are loaded). Still not fantastic, but it's the best
available, AFAIK.
Cheers,
- jonathan
|
|
|
|
|