Shared Memory Problem

Liz_Watson%anvil.UUCP at harvard.harvard.edu Liz_Watson%anvil.UUCP at harvard.harvard.edu
Thu Apr 3 13:54:36 AEST 1986


Bruce Holloway writes:
>I'm having a problem with the shared memory routines under System V, and
>I wonder if any gurus out there could help me....
>
>    mes = (MES *)shmat(shmid, (char *)0, 0);
>    if(!mes){ printf("SHMAT failed!\n"); return; }
>
>/* Core is dumped on next statement */
>
>    mes->mes_flags = 0;
>

First, fix up your error check on the shmat.  When shmat
fails, it returns a -1.  This causes your core dump.

The shmat call fails because the shmget call did not give
adequate (any) permissions.  The shmat requires at least
read permission.  The permissions are set by shmget,
using the low-order 9 bits of shmflag.


Liz Watson
Stratus Comp



More information about the Comp.unix.wizards mailing list