When using the fork system call in C++, what is the easiest way to kill a child process if it takes too much time to execute what it is supposed to execute?
Like if somehow it gets into an infinite loop.. What should the parent process do to set the timeout for the child process?
Use
WNOHANGwithwaitpidand sleep in between. Something like this should do it: