최종 결과를 얻기 위해 여러 개의 I/O 파이프 (프로세스 당 하나의 파이프)를 사용하는 mapreduce 프로그램을 작성 중입니다. 프로세스를 만드는 데 문제가 있습니다. 특히, 나는 다음과 같은 오류를 얻고 것은 : 나는이 쓰레드가 선택 사용하는 하나 개의 스레드fork() - 여러 프로세스와 시스템 호출
pthread_t newThread;
pthread_create(&newThread,NULL,threadFunction,values);
pthread_join(newThread,NULL);
를 생성하고이 후
while (values[inc]!=NULL) //provided array of text lines
{
if ((pid = fork()) == -1) {
perror("fork error");
exit(EXIT_FAILURE);
}
else if (pid == 0) { /* start of child process */
printf("Child process...\n");
/* pipes[inc][1] is a file descriptor to which myMap writes some data
using the write() system call
mr is a struct that holds other function pointers */
mr->myMap(pipes[inc][1],values[inc]);
exit(0);
}
else { /* start of parent process */
printf("Parent process...\n");
if ((wpid = wait(&status)) == -1)
/* Wait for child process. */
perror("wait error");
else { /* Check status. */
if (WIFSIGNALED(status) != 0)
printf("Child process ended because of signal %d\n",
WTERMSIG(status));
else if (WIFEXITED(status) != 0)
printf("Child process ended normally; status = %d\n",
WEXITSTATUS(status));
else
printf("Child process did not end normally\n");
}
//close(fd[1]);
printf("Parent process ended\n");
}
inc++;
}
(:
wait error: Interrupted system call
이 프로세스를 생성합니다 내 코드입니다) 함수를 사용하여 읽을 준비가 된 파일 설명자를 찾고이를 읽고 사전에 데이터를 넣습니다.
형태 GDB 디버거, 프로그램 출력을 실행하는 경우 :
Parent process...
Child process...
wait error: Interrupted system call
Parent process ended
Parent process...
Child process ended normally; status = 0
Parent process ended
Parent process...
Child process...
Child process...
wait error: Interrupted system call
Parent process ended
내가 문제를 해결하는 방법을 모르겠어요. 어떤 제안?
감사합니다.
난 당신이 무슨 뜻인지 모르겠어요. 제발 좀 더 자세히 설명해주세요. – Krzysiek
@Rafcio 답변을 업데이트했습니다. – trojanfoe
감사합니다. 말된다! :) – Krzysiek