Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] shmget fails with error code = 22



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));
}


Attachment: signature.asc
Description: PGP signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links