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
#include <unistd.h> /* define fork(), etc. */
#include <sys/types.h> /* define pid_t, etc. */
#include <sys/wait.h> /* define wait(), etc. */
#include <signal.h> /* define signal(), etc. */
int main (void)
{
int child_pid;
int i;
int child_status;
/* The child process forking code... */
child_pid = fork();
switch (child_pid) {
case -1: /* fork() failed */
perror("fork");
exit(1);
case 0:
/* inside child process */
sleep(2);
printf("Iam child with pid: %d,Iam now sending my signal!\n", getpid());
signal(SIGINT, SIG_IGN);
case 1:
sleep(5);/* sleep a little, so we'll have */
printf("Iam child with pid: %d,Iam now sending my signal!\n", getpid());
signal(SIGINT, SIG_IGN);
printf("Son! Stop Making Noise!\n");
exit(0);
default: /* inside parent process */
break;
}
/* Afer waiting, the parent process goes on... */
/* for example, some output... */
for (i=0; i<10; i++) {
printf("%d\n", i);
sleep(1); /* sleep for a second, so we'll have time to see the mix */
}
return 0;
}
Can somebody help me?