I am new in C programming and was asked to write a simple program with these requirements:
creates a separate process to execute the external program,
doStuff
waits for 10 seconds
sends an
SIGUSR1
signal to the child process, andobtains and prints the exit status of the child process.
I do not really have the doStuff
with me.
I am not sure how to meet the last requirement, should I use waitpid()
? I haven't learned it yet. May I know how to apply that to my program as
Here is the code I did, I know is simple so I am not sure did I do it rightly. May anyone can kindly let me know am I doing it on the right direction?
Thank you so much.
#include <stdio.h>
#include <signal.h>
#include "doStuff.h"
// which inculde the funcion "doStuff"
int main()
{
doStuff();
sleep(10);
signal(SIGUSR1, doStuff);
}