strace.c: move termination code to a separate function

This will be needed for the pull-style API.

* strace.c (terminate): New function.
(main): Use it.
This commit is contained in:
Victor Krapivensky 2017-06-05 14:46:34 +03:00 committed by Dmitry V. Levin
parent e6cdfb6e84
commit 0a9d8bfd84

View File

@ -2573,18 +2573,9 @@ dispatch_event(enum trace_event ret, int *pstatus, siginfo_t *si)
extern void __gcov_flush();
#endif
int
main(int argc, char *argv[])
static void ATTRIBUTE_NORETURN
terminate(void)
{
init(argc, argv);
exit_code = !nprocs;
int status;
siginfo_t si;
while (dispatch_event(next_event(&status, &si), &status, &si))
;
cleanup();
fflush(NULL);
if (shared_log != stderr)
@ -2619,6 +2610,19 @@ main(int argc, char *argv[])
Exit with 128 + signo then. */
exit_code += 128;
}
return exit_code;
exit(exit_code);
}
int
main(int argc, char *argv[])
{
init(argc, argv);
exit_code = !nprocs;
int status;
siginfo_t si;
while (dispatch_event(next_event(&status, &si), &status, &si))
;
terminate();
}