unsigned os_release; /* generated from uname()'s u.release */
static void detach(struct tcb *tcp);
-static int trace(void);
static void cleanup(void);
static void interrupt(int sig);
static sigset_t empty_set, blocked_set;
interrupted = sig;
}
-static int
+static void
trace(void)
{
struct rusage ru;
unsigned event;
if (interrupted)
- return 0;
+ return;
if (interactive)
sigprocmask(SIG_SETMASK, &empty_set, NULL);
continue;
if (wait_errno == ECHILD)
/* Should not happen since nprocs > 0 */
- return 0;
+ return;
errno = wait_errno;
- perror_msg("wait4(__WALL)");
- return -1;
+ perror_msg_and_die("wait4(__WALL)");
}
if (pid == popen_pid) {
if (clearbpt(tcp) < 0) {
/* Pretty fatal */
droptcb(tcp);
- cleanup();
- return -1;
+ exit_code = 1;
+ return;
}
}
if (ptrace_setoptions) {
* (that is, process really stops. It used to continue to run).
*/
if (ptrace_restart(PTRACE_LISTEN, tcp, 0) < 0) {
- cleanup();
- return -1;
+ /* Note: ptrace_restart emitted error message */
+ exit_code = 1;
+ return;
}
continue;
}
/* We handled quick cases, we are permitted to interrupt now. */
if (interrupted)
- return 0;
+ return;
/* This should be syscall entry or exit.
* (Or it still can be that pesky post-execve SIGTRAP!)
sig = 0;
restart_tracee:
if (ptrace_restart(PTRACE_SYSCALL, tcp, sig) < 0) {
- cleanup();
- return -1;
+ /* Note: ptrace_restart emitted error message */
+ exit_code = 1;
+ return;
}
- }
- return 0;
+ } /* while (nprocs != 0) */
}
int
init(argc, argv);
/* Run main tracing loop */
- if (trace() < 0)
- return 1;
+ trace();
cleanup();
fflush(NULL);