Run time(1) children in their own process group.
This commit is contained in:
parent
ebb75f656c
commit
f384fcdff1
|
@ -40,13 +40,18 @@ int main(int argc, char* argv[])
|
||||||
error(1, errno, "fork");
|
error(1, errno, "fork");
|
||||||
if ( !child_pid )
|
if ( !child_pid )
|
||||||
{
|
{
|
||||||
|
setpgid(child_pid, child_pid);
|
||||||
|
tcsetpgrp(0, child_pid);
|
||||||
if ( argc <= 1 )
|
if ( argc <= 1 )
|
||||||
exit(0);
|
exit(0);
|
||||||
execvp(argv[1], argv+1);
|
execvp(argv[1], argv+1);
|
||||||
error(127, errno, "%s", argv[1]);
|
error(127, errno, "%s", argv[1]);
|
||||||
}
|
}
|
||||||
|
setpgid(child_pid, child_pid);
|
||||||
|
tcsetpgrp(0, child_pid);
|
||||||
int exit_status = 0;
|
int exit_status = 0;
|
||||||
waitpid(child_pid, &exit_status, 0);
|
waitpid(child_pid, &exit_status, 0);
|
||||||
|
tcsetpgrp(0, getpgid(0));
|
||||||
|
|
||||||
struct timespec end_time;
|
struct timespec end_time;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &end_time);
|
clock_gettime(CLOCK_MONOTONIC, &end_time);
|
||||||
|
|
Loading…
Reference in New Issue