Hi..
Iam facing a problem in the code the output should look like that:
0
1
2
I am child with pid: 22735. I am, now sending my signal!
3
4
5
I am child with pid: 22736. I am, now sending my signal!
Son! Stop making noise!
6
7
8
9
but, iam not getting what I want
this is my code..it is in c program
Can somebody help me?
Last edited by Perderabo; 03-26-2006 at 09:15 PM..
Reason: Add code tags for readability
You want those printf's to send output when they are called. But printf may be buffered. Call setvbuf early in the program to turn off buffering. The child should not call signal. That is not the way to send a signal. It must call kill() to send a signal. It will need the pid of the parent. It can use getppid() for that. Look again at the docs for signal(). Yes the parent needs to call it. But SIG_IGN says to ignore the signal. Do you want the parent to ignore the signal? And, by the way, fork() creates one new process. The child will get a return code of zero. But you have "case 1". The return for the parent is the pid of the child, this will not be 1 ever. This should be enough hints to get you closer.