2014-01-12 4 views
0

Windows에서 cygwin에서 다음 코드를 실행하려고했습니다. 거기에 컴파일 오류가있을 것입니다하지만 그것을 실행하려고했을 때 잘못된 시스템 호출 (코어 덤프) 오류가 발생했습니다.cygwin에서 공유 메모리 프로그램 실행

#include <sys/types.h> 
#include <sys/ipc.h> 
#include <sys/shm.h> 
#include <stdio.h> 
#include <stdlib.h> 
void main () 
{ int shm_id; key_t mem_key; 
int *shm_ptr; 
mem_key = ftok(".", 'a'); 
shm_id = shmget(mem_key, sizeof(int), IPC_CREAT | 0666); 
if (shm_id < 0) 
{ printf("*** shmget error (server) ***\n"); 
exit(1); 
} 
shm_ptr = (int *) shmat(shm_id, NULL, 0); 
/* attach */ 
if ((int) shm_ptr == -1) 
{ 
printf("*** shmat error (server) ***\n"); 
exit(1); 
} 
} 

왜이 오류가 있습니까? 내가 해결할 수 있을까?

고마워요.

답변

1

cygserver를 구성하고 시작해야합니다.

관련 문제