Sto scrivendo un programma di mapreduce che utilizza più pipe di I/O (un pipe per processo) per ottenere risultati finali. Sto avendo un problema con la creazione dei processi. In particolare, sto ottenendo il seguente errore:fork() - più chiamate di sistema e di processo
wait error: Interrupted system call
Questo è il mio codice che genera processi:
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++;
}
Dopo questo, io sono la creazione di un thread
pthread_t newThread;
pthread_create(&newThread,NULL,threadFunction,values);
pthread_join(newThread,NULL);
Il threadFunction utilizza select () per scoprire quale file descriptor è pronto per essere letto e letto e mette i dati in un dizionario.
Durante l'esecuzione del debugger gdb forma, l'output del programma:
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
non so come risolvere il problema. Eventuali suggerimenti?
Grazie!
non sono sicuro di quello che vuoi dire. Si prega di elaborare. – Krzysiek
@Rafcio Ho aggiornato la mia risposta. – trojanfoe
Grazie. Ha senso! :) – Krzysiek