#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
void catch_alarm(int sig_num) {
printf('Child proccess will Exit..
'); & nbsp; & nbsp;
exit(0);
}
void myfunc(int sig) {
signal(SIGALRM, catch_alarm);
alarm(15);
while (1) {
printf('I am the child
');
}
}
int main(){
int pid;
signal(SIGALRM, catch_alarm);
pid = fork();
if (pid = 0) {
while (1) {
printf('I am the child
');
}
} else {
if (!pid == 0) {
sleep(3);
printf('Mypid is : %d
',getpid());
signal(SIGINT,myfunc);
}
}
}
Φόρουμ
Δώσε αστέρια!
- Συνδεθείτε ή εγγραφείτε για να σχολιάσετε