is there way forked child examine forked child that, if other forked child takes more time usual perform chores, first child may perform predefined steps? if so, sample code appreciated.
yes. fork process watched, from process watch it.
if (fork() == 0) { // watcher pid_t watchee_pid = fork(); if (watchee_pid != 0) { // wait and/or handle timeout int status; waitpid(watchee_pid, &status, wnohang); } else { // we're being watched. stuff } } else { // original process }
to emphasise: there 3 processes. original, watcher process (that handles timeout etc.) , actual watched process.
Comments
Post a Comment