So I have a section of my code that I only want to run before the child process has been forked but am getting stuck
main()
{
if (!childpid)
{
signal (SIGINT, siginthandler);
signal (SIGQUIT, sigquithandler);
signal (SIGUSR1, sigusr1handler);
while (!done)
{
printf("\nWait for another signal\n");
pause();
}
}
}
void sigquithandler ()
{
childpid = fork();
if (childpid == 0)
{
printf("\tI am the child and I am sending a signal\n");
kill(getppid(), SIGUSR1);
exit(0);
}
}
So basically the sigquit will end everything and I dont want to print "wait for another signal" after pressing ctrl-\ so I am trying to only execute the code in main before the child process has been forked then after it is forked it will end
Any help is appreciated!!
Aucun commentaire:
Enregistrer un commentaire