I have two following source files
loop.c which executable name is loop
int main() {
while(true);
return 0;
}
and run.c which executable name is run
int main() {
pid_t child_pid = fork();
int status;
struct rusage info;
if (child_pid == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("loop", "loop", NULL);
exit(0);
}
wait4(child_pid, &status, 0, &info);
puts("Child exited");
printf("%ld\n", info.ru_utime.tv_usec);
return 0;
}
I've compiled both and I've ran run
program. Why it terminated? I've read that wait4 suspend, but in fact it does not. When I've executed ps
program loop
is running and run
does not (it's not in ps
and terminal seems to finish it's work by giving an output).
Am I missing something?
PS
I used gnu g++ compiler if it's matters.