}
else if (signo == SIGTERM) {
fprintf(stderr, "[%s] > Signalling other processes..\n", "process1");
- processes->pids[1] = 0;
+ processes->pids[0] = 0;
notify_other_processes(signo);
fprintf(stderr, "[%s] > Releasing resources\n", "process1");
exit(0);
}
else if (signo == SIGTSTP) {
+ fprintf(stderr, "[%s] > Signalling other processes..\n", "process1");
+ processes->pids[0] = 0;
+ notify_other_processes(signo);
+// sleep(1);
+ processes->pids[0] = getpid();
+
fprintf(stderr, "[%s] > Closing pipe\n", "process1");
close(write_pipe);
raise (SIGSTOP);
else if (signo == SIGCONT) {
fprintf(stderr, "[%s] > Opening pipe\n", "process1");
file_descriptor = open(write_pipe, O_WRONLY);
+ processes->pids[0] = 0;
+ notify_other_processes(signo);
+// sleep(1);
+ processes->pids[0] = getpid();
}
}
else if (signo == SIGTSTP) {
fprintf(stderr, "[%s] > Close reading pipe\n", "process2");
close(read_descriptor);
+ processes->pids[1] = 0;
notify_other_processes(signo);
+// sleep(1);
+ processes->pids[1] = getpid();
+
fprintf(stderr, "[%s] > Close writing pipe\n", "process2");
close(write_descriptor);
raise (SIGSTOP);
}
else if (signo == SIGCONT) {
fprintf(stderr, "[%s] > Signalling other processes..\n", "process2");
+ processes->pids[1] = 0;
notify_other_processes(signo);
+// sleep(1);
+ processes->pids[1] = getpid();
fprintf(stderr, "[%s] > Opening pipes\n", "process2");
write_descriptor = open(write_pipe, O_WRONLY);
}
else if (signo == SIGTSTP) {
fprintf(stderr, "[%s] > Signalling other processes..\n", "process3");
+ processes->pids[2] = 0;
notify_other_processes(signo);
+// sleep(1);
+ processes->pids[2] = getpid();
fprintf(stderr, "[%s] > Closing pipe\n", "process3");
close(read_descriptor);
}
else if (signo == SIGCONT) {
fprintf(stderr, "[%s] > Signalling other processes..\n", "process3");
+ processes->pids[2] = 0;
notify_other_processes(signo);
+// sleep(1);
+ processes->pids[2] = getpid();
fprintf(stderr, "[%s] > Opening pipe\n", "process3");
read_descriptor = open(read_pipe, O_RDONLY);