Topic: ipc


Author: hagins@avlin8.us.dg.com (Jody Hagins)
Date: Wed, 31 Mar 93 15:13:05 GMT
Raw View
In article <1993Mar28.163858.24393@wuecl.wustl.edu>, ppc2@cec1.wustl.edu (Peter P Chiu) writes:
*>
*> hi everyone,
*>
*> i want to be able to use C++ classes in IPC programs but i can't get them
*> compiled using C++.  here is an example:
*>
*> Script started on Sun Mar 28 10:32:19 1993
*> [cec1] ~ > cat ipc.c
*> #include <sys/time.h>
*> #include <sys/types.h>
*> #include <sys/ipc.h>
*> #include <sys/shm.h>
*> #include <sys/sem.h>
*> #include <stdio.h>
*>
*> main()
*> {
*>
*>  int             shmid, semid;
*>
*>  fork();
*>  shmid = shmget(IPC_PRIVATE, 80, IPC_CREAT | 0600);
*>  semid = semget(IPC_PRIVATE, 13, IPC_CREAT | 0600);
*>  shmctl(shmid, IPC_RMID, NULL);
*>  semctl(semid, IPC_RMID, NULL);
*>
*> }
*> [cec1] ~ > cc ipc.c
*> [cec1] ~ > addpkg c++
*> -- Accessible Packages: c++ standard
*> -- Type help unix packages for more info.
*> [cec1] ~ > CC ipc.c
*> "ipc.c", line 13: error:  undefined function fork called
*> "ipc.c", line 17: error:  argument  4 of type union semun  expected for semctl()

Try including unistd.h to get the fork() prototype.

You left out the fourth argument to semctl().  Here is the prototype:

int semctl (int semid,
            int semid,
            int semnum,
            int cmd,
            union semun
            {
              int val;
              struct semid_ds *buf;
              unsigned short *array;
            } arg);


*> Compilation failed
*> [cec1] ~ > exit
*> exit
*>
*> script done on Sun Mar 28 10:32:45 1993
*>
*> can anyone please give me a hand?
*>
*> please send email to ppc2@cec1.wustl.edu
*>
*> thank you very much in advance
*>
*> peter
*>

--