Code Comments
Programming Forum and web based access to our favorite programming groups.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 ????
Post Follow-up to this messageOn 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
Post Follow-up to this messageMichael 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.")
Post Follow-up to this messageRobert 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)
Post Follow-up to this messageJuha 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
Post Follow-up to this messageRobert 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 erro r > 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
Post Follow-up to this messageJonathan 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.")
Post Follow-up to this messageIn 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 t o > 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.