
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[solved] Re: [tlug] shmget fails with error code = 22
2008/1/15, Botond Botyanszki <tlug@example.com>:
> On Tue, 15 Jan 2008 20:32:50 +0900
> "Nguyen Vu Hung" <vuhung16plus@example.com> wrote:
>
> > Hi,
> >
> > The following code has failed and the error code ( errno ) is 22.
> >
> >
> > shmid = shmget((key_t)ShmKey, (size_t)mem_size, 0666 | IPC_CREAT);
> > iErrorCode = errno;
> >
> >
> > I've checked /usr/include/asm/error.h and found that
> >
> > #define EINVAL 22 /* Invalid argument */
> >
> > which is not very informative.
>
> If you check the manpage on linux, it says:
> EINVAL A new segment was to be created and size < SHMMIN or size >
> SHMMAX, or no new segment was to be created, a segment with
> given key existed, but size is greater than the size of
> that segment.
>
> Adding proper error handling with debug helpers to your code can help a
> lot is such situations, ie:
> if ( errno != 0 )
> {
> fprintf(STDERR, "shmget(mem_size: %d) failed, %s", mem_size, strerror(errno));
> }
I did have an error handling.
The cause of the problem turns out to be: We tried to shmget() with
mem_size = 64MB but the shared memory, which was created before that,
is a different value. The size of shared memory is define in
configuration file someone has changed it.
Thanks all for hinting me.
--
Best Regards,
Nguyen Hung Vu ( Nguyễn Vũ Hưng )
vuhung16plus{remove}@example.com
An inquisitive look at Harajuku
http://www.flickr.com/photos/vuhung/sets/72157600109218238/
Home |
Main Index |
Thread Index