static pthread_mutex_t stdout_mutex = PTHREAD_MUTEX_INITIALIZER;
+static void exit_trace(int status);
+
static int find_mask_map(char *string)
{
int i;
}
}
-static void exit_trace(int status)
-{
- stop_trace();
- exit(status);
-}
-
static void extract_data(struct thread_information *tip, char *ofn, int nb)
{
int ret, bytes_left;
return ncpus;
}
+static void close_thread(struct thread_information *tip)
+{
+ if (tip->fd != -1)
+ close(tip->fd);
+ if (tip->ofd != -1)
+ close(tip->ofd);
+ tip->fd = tip->ofd = -1;
+}
+
static void stop_threads(void)
{
struct thread_information *tip = thread_information;
if (pthread_join(tip->thread, (void *) &ret))
perror("thread_join");
-
- close(tip->fd);
- close(tip->ofd);
+ close_thread(tip);
}
}
+static void stop_tracing(void)
+{
+ struct thread_information *tip = thread_information;
+ int i;
+
+ for (i = 0; i < ncpus; i++, tip++)
+ close_thread(tip);
+ stop_trace();
+}
+
+static void exit_trace(int status)
+{
+ stop_tracing();
+ exit(status);
+}
+
static void show_stats(void)
{
int i;
signal(SIGHUP, handle_sigint);
signal(SIGTERM, handle_sigint);
- atexit(stop_trace);
+ atexit(stop_tracing);
while (!is_done())
sleep(1);