*/
void sig_handler(int signo)
{
+ fprintf(stderr, "[%s] Received %s!\n", "process1", strsignal(signo));
if (signo == SIGUSR1) {
- fprintf(stderr, "[%s] Received SIGUSR1!\n", "process1");
}
else if (signo == SIGTERM) {
- fprintf(stderr, "[%s] Received SIGTERM!\n", "process1");
fprintf(stderr, "[%s] > Releasing resources\n", "process1");
close(write_pipe);
unlink(write_pipe);
}
exit(0);
}
- else if (signo == SIGINT) {
- fprintf(stderr, "[%s] Received SIGINT!\n", "process1");
+ else if (signo == SIGTSTP) {
fprintf(stderr, "[%s] > Closing pipe\n", "process1");
close(write_pipe);
}
else if (signo == SIGCONT) {
- fprintf(stderr, "[%s] Received SIGCONT!\n", "process1");
fprintf(stderr, "[%s] > Opening pipe\n", "process1");
file_descriptor = open(write_pipe, O_WRONLY);
}
if (signal(SIGTERM, sig_handler) == SIG_ERR) {
fprintf(stderr, "can't catch SIGTERM\n");
}
- if (signal(SIGINT, sig_handler) == SIG_ERR) {
- fprintf(stderr, "can't catch SIGINT\n");
+ if (signal(SIGTSTP, sig_handler) == SIG_ERR) {
+ fprintf(stderr, "can't catch SIGTSTP\n");
}
if (signal(SIGCONT, sig_handler) == SIG_ERR) {
fprintf(stderr, "can't catch SIGCONT\n");
*/
void sig_handler(int signo)
{
+ fprintf(stderr, "[%s] Received %s!\n", "process2", strsignal(signo));
if (signo == SIGUSR1) {
- fprintf(stderr, "[%s] Received SIGUSR1!\n", "process2");
}
else if (signo == SIGTERM) {
- fprintf(stderr, "[%s] Received SIGTERM!\n", "process2");
fprintf(stderr, "[%s] > Releasing resources\n", "process2");
close(read_descriptor);
close(write_descriptor);
unlink(write_descriptor);
exit(0);
}
- else if (signo == SIGINT) {
- fprintf(stderr, "[%s] Received SIGINT!\n", "process2");
+ else if (signo == SIGTSTP) {
fprintf(stderr, "[%s] > Closing pipes\n", "process2");
close(read_descriptor);
close(write_descriptor);
}
else if (signo == SIGCONT) {
- fprintf(stderr, "[%s] Received SIGCONT!\n", "process2");
fprintf(stderr, "[%s] > Opening pipes\n", "process2");
read_descriptor = open(read_pipe, O_RDONLY);
write_descriptor = open(write_pipe, O_WRONLY);
if (signal(SIGTERM, sig_handler) == SIG_ERR) {
fprintf(stderr, "can't catch SIGTERM\n");
}
- if (signal(SIGINT, sig_handler) == SIG_ERR) {
- fprintf(stderr, "can't catch SIGINT\n");
+ if (signal(SIGTSTP, sig_handler) == SIG_ERR) {
+ fprintf(stderr, "can't catch SIGTSTP\n");
}
if (signal(SIGCONT, sig_handler) == SIG_ERR) {
fprintf(stderr, "can't catch SIGCONT\n");
*/
void sig_handler(int signo)
{
+ fprintf(stderr, "[%s] Received %s!\n", "process3", strsignal(signo));
if (signo == SIGUSR1) {
- fprintf(stderr, "[%s] Received SIGUSR1!\n", "process3");
}
else if (signo == SIGTERM) {
- fprintf(stderr, "[%s] Received SIGTERM!\n", "process3");
fprintf(stderr, "[%s] > Releasing resources\n", "process3");
close(read_descriptor);
exit(0);
}
- else if (signo == SIGINT) {
- fprintf(stderr, "[%s] Received SIGINT!\n", "process3");
- fprintf(stderr, "[%s] > Closing pipe\n", "process2");
+ else if (signo == SIGTSTP) {
+ fprintf(stderr, "[%s] > Closing pipe\n", "process3");
close(read_descriptor);
}
else if (signo == SIGCONT) {
- fprintf(stderr, "[%s] Received SIGCONT!\n", "process3");
- fprintf(stderr, "[%s] > Opening pipe\n", "process2");
+ fprintf(stderr, "[%s] > Opening pipe\n", "process3");
read_descriptor = open(read_pipe, O_RDONLY);
}
}
if (signal(SIGTERM, sig_handler) == SIG_ERR) {
fprintf(stderr, "can't catch SIGTERM\n");
}
- if (signal(SIGINT, sig_handler) == SIG_ERR) {
- fprintf(stderr, "can't catch SIGINT\n");
+ if (signal(SIGTSTP, sig_handler) == SIG_ERR) {
+ fprintf(stderr, "can't catch SIGTSTP\n");
}
if (signal(SIGCONT, sig_handler) == SIG_ERR) {
fprintf(stderr, "can't catch SIGCONT\n");