#include #include #include #include #include #include int main (int ac, char **av) { int seg, stat; if ((seg = shmget (IPC_PRIVATE, 4000, IPC_CREAT| 0600)) == -1) { perror("shmget"); exit (1); } if (shmat (seg, 0, 0) == (void*) -1) { perror ("shmat"); exit (2); } if (shmctl (seg, IPC_RMID, NULL) == -1) { perror ("shmctl"); exit (2); } switch (fork()) { case -1: perror ("fork"); return (3); case 0: if (shmat (seg, 0, 0) != (void*) -1) printf ("shmat in client ok\n"); else perror ("shmat in client failed"); return (0); default: wait(&stat); } exit (0); }