Judger/tests/test_src/integration/child_proc_cpu_time_limit.c
2016-10-24 23:01:55 +08:00

29 lines
485 B
C

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/types.h>
int main()
{
int status;
int pid;
if ((pid = fork()) < 0) {
perror("fork error");
return 0;
}
if (pid == 0) {
while (1) {};
}
else {
struct rusage resource_usage;
if (wait4(pid, &status, 0, &resource_usage) == -1) {
perror("wait4 error!");
}
}
return 0;
}