process group = job, and signal question
- From: Schüle Daniel <uval@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Jun 2006 22:57:34 +0200
Hello all,
I have written 2 small programs to test the signal delivering
behaviour
// pipewriter.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
void sigint(int signum){
printf("writer INT\n");
exit(0);
}
int main(void){
char alphabet[] = "abcdefghijklmnopqrstxyz";
int i = 0;
signal(SIGINT, sigint);
while(1){
if(i >= sizeof alphabet)
i = 0;
sleep(1);
printf("%c", alphabet[i++]);
fflush(stdout);
}
return 0;
}
// pipereader.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
char buff[256] = {0};
void sigint(int signum){
printf("reader INT\n");
printf("buffer = %s\n", buff);
exit(0);
}
int main(void){
signal(SIGINT, sigint);
while(1){
fgets(buff, sizeof buff / sizeof buff[0], stdin);
}
return 0;
}
finally I let pipewriter write into the pipe
../pipewriter | ./pipereader
and after 7 seconds I send SIGINT (type cntr-Z in terminal)
this is the message I see
reader INT
buffer = abcdefg
well, does this mean that only last process in the pipe
executes its "sigint" handler?
does it become process leader?
sometimes a program may release resources in the signal handler
not executing all of them would mean resoure leakage, doesn't it?
thanks in advance
Regards, Daniel
.
- Follow-Ups:
- Re: process group = job, and signal question
- From: Bill Pursell
- Re: process group = job, and signal question
- Prev by Date: Re: stream device reading
- Next by Date: Re: GTK application query
- Previous by thread: GTK application query
- Next by thread: Re: process group = job, and signal question
- Index(es):
Relevant Pages
|