timeradd(&rus->ru_utime, &rus->ru_stime, &total);
total_ms = total.tv_sec*1000 + total.tv_usec/1000;
gettimeofday(&now, NULL);
- // FIXME: We are not guaranteed to have start_time always initialized
timersub(&now, &start_time, &wall);
wall_ms = wall.tv_sec*1000 + wall.tv_usec/1000;
partial_line = 0;
}
+/* Report an error of the sandbox itself */
static void NONRET __attribute__((format(printf,1,2)))
die(char *msg, ...)
{
box_exit(2);
}
+/* Report an error of the program inside the sandbox */
static void NONRET __attribute__((format(printf,1,2)))
err(char *msg, ...)
{
box_exit(1);
}
+/* Write a message, but only if in verbose mode */
static void __attribute__((format(printf,1,2)))
msg(char *msg, ...)
{
S(fcntl) = A_YES,
S(fcntl64) = A_YES,
S(mmap) = A_YES,
+ S(mmap2) = A_YES,
S(munmap) = A_YES,
S(ioctl) = A_YES,
S(uname) = A_YES,
S(gettid) = A_YES,
S(set_thread_area) = A_YES,
S(get_thread_area) = A_YES,
+ S(set_tid_address) = A_YES,
S(exit_group) = A_YES,
// Syscalls permitted only in liberal mode
S(rt_sigtimedwait) = A_YES | A_LIBERAL,
S(rt_sigqueueinfo) = A_YES | A_LIBERAL,
S(rt_sigsuspend) = A_YES | A_LIBERAL,
- S(mmap2) = A_YES | A_LIBERAL,
S(_sysctl) = A_YES | A_LIBERAL,
#undef S
};
{
box_pid = 0;
final_stats(&rus);
- // FIXME: If the process has exited before being ptraced, signal an internal error
if (WEXITSTATUS(stat))
{
- meta_printf("exitcode:%d\n", WEXITSTATUS(stat));
- err("RE: Exited with error status %d", WEXITSTATUS(stat));
+ if (syscall_count)
+ {
+ meta_printf("exitcode:%d\n", WEXITSTATUS(stat));
+ err("RE: Exited with error status %d", WEXITSTATUS(stat));
+ }
+ else
+ {
+ // Internal error happened inside the child process and it has been already reported.
+ box_exit(2);
+ }
}
if (timeout && total_ms > timeout)
err("TO: Time limit exceeded");