So I want to create a process and keep it running for a certain amount of time, before calling SIGINT on it and killing it.
So what I have done is created a struct pcb (process control block), and when I have this process running i set
mypcb->status = RUN //RUN would just be defined as 0, SUSPEND as 1, etc
Basically I have a function that manages all my processes, and I might have in this function something like
startprocess(processnum);
wait 10 seconds
killprocess(processnum);
So then in my startprocess function I call fork, and in the child process (when fork() == 0), I want to keep this process running indefinitely. I know this can probably be done by using execvp, but I don't want to switch context to another exe file, I just want to keep the process running, or at least make it seem like the child process is still alive so that I can go back and call SIGINT on the pid in my killprocess function.
Note that I store the pid of each process in
mypcb->pid
so i dont need to pass anything, I just need a way to keep the process running so I can go back and kill it after.
Hopefully my question makes sense, basically I just want to know how I can keep a process running without it doing anything, so that I can kill it later.
Thanks!