c - How can I simulate a process running? -


so want create process , keep running amount of time, before calling sigint on , killing it.

so have done created struct pcb (process control block), , when have process running set

mypcb->status = run //run defined 0, suspend 1, etc 

basically have function manages processes, , might have in function

startprocess(processnum); wait 10 seconds killprocess(processnum); 

so in startprocess function call fork, , in child process (when fork() == 0), want keep process running indefinitely. know can done using execvp, don't want switch context exe file, want keep process running, or @ least make seem child process still alive can go , call sigint on pid in killprocess function.

note store pid of each process in

mypcb->pid 

so dont need pass anything, need way keep process running can go , kill after.

hopefully question makes sense, want know how can keep process running without doing anything, can kill later.

thanks!

it sounds you're trying make process run forever doing nothing in particular (and in case rest of question irrelevant).

you can use like:

while(1) {     /* no code in between {} */ } 

which nothing, forever.


Popular posts from this blog