Versione finale del client ECHO su TCP, con esempio di uso della funzione
[gapil.git] / listati / IPCTestId.c
1 int main(int argc, char *argv[])
2 {
3     ...
4     switch (type) {
5     case 'q':   /* Message Queue */
6         debug("Message Queue Try\n");
7         for (i=0; i<n; i++) {
8             id = msgget(IPC_PRIVATE, IPC_CREAT|0666);
9             printf("Identifier Value %d \n", id);
10             msgctl(id, IPC_RMID, NULL);
11         }
12         break;
13     case 's':   /* Semaphore */
14         debug("Semaphore\n");
15         for (i=0; i<n; i++) {
16             id = semget(IPC_PRIVATE, 1, IPC_CREAT|0666);
17             printf("Identifier Value %d \n", id);
18             semctl(id, 0, IPC_RMID);
19         }
20         break;
21     case 'm':   /* Shared Memory */
22         debug("Shared Memory\n");
23         for (i=0; i<n; i++) {
24             id = shmget(IPC_PRIVATE, 1000, IPC_CREAT|0666);
25             printf("Identifier Value %d \n", id);
26             shmctl(id, IPC_RMID, NULL);
27         }
28         break;
29     default:    /* should not reached */
30         return -1;
31     }
32     return 0;
33 }