'soir, je cherche a echanger une structure entre deux processus sous cygwin et lorsque je lance les programmes j'ai "Bad System Call". Voic mon code:

Emission
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/sem.h>
 
typedef struct{
               int a;
               int b;
               int c;
               }T_test;
 
int main()
{
 
 int msqid;
 int msgflg = IPC_CREAT | 0666;
 key_t key;
 T_test test;
 
 key = 1234;
 
 test.a = 1;
 test.b = 2;
 test.c = 3;
 
 if((msqid = msgget(key, msgflg )) < 0)
 {
  perror("msgget");
  exit(1);
 }
 
 if (msgsnd(msqid, &test, sizeof(T_test), IPC_NOWAIT) < 0)
 {
  perror("msgsnd");
  exit(1);
 }
 
 return 0;
}
Reception
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/sem.h>
 
typedef struct{
               int a;
               int b;
               int c;
               }T_test;
 
 
int main()
{
 
 int msqid;
 key_t key;
 T_test test;
 
 key = 1234;
 
 if((msqid = msgget(key, 0666)) < 0)
 {
  perror("msgget");
  exit(1);
 }
 
 if(msgrcv(msqid, &test, sizeof(T_test), 0, 0) < 0)
 {
  perror("msgrcv");
  exit(1);
 }
 
 printf("\n%d, %d, %d\n", test.a, test.b, test.b);
 return 0;
}
Merci!!