This will be needed for the pull-style API.

* strace.c (terminate): New function.
(main): Use it.
---
 strace.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/strace.c b/strace.c
index af5fd346..5accb141 100644
--- a/strace.c
+++ b/strace.c
@@ -2593,18 +2593,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)
@@ -2639,6 +2630,19 @@ main(int argc, char *argv[])
                   Exit with 128 + signo then.  */
                exit_code += 128;
        }
+       exit(exit_code);
+}
+
+int
+main(int argc, char *argv[])
+{
+       init(argc, argv);
 
-       return exit_code;
+       exit_code = !nprocs;
+
+       int status;
+       siginfo_t si;
+       while (dispatch_event(next_event(&status, &si), &status, &si))
+               ;
+       terminate();
 }
-- 
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to