X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libust%2Ftracectl.c;h=2d4341d3b418cd4957b8ab2efc95fbf564f6520e;hb=c5fdc88852bc232e24fb3941ea5d5719b4490a87;hp=1dd71621e0e147ba471c97c02366de92171ccfea;hpb=ed1317e78616d3fb99791d4effef7473317c41ec;p=lttng-ust.git diff --git a/libust/tracectl.c b/libust/tracectl.c index 1dd71621..2d4341d3 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -27,7 +27,7 @@ #include #include -#include +#include #include "marker.h" #include "tracer.h" @@ -63,10 +63,6 @@ struct tracecmd { /* no padding */ /* volatile because shared between the listener and the main thread */ volatile sig_atomic_t buffers_to_export = 0; -//struct listener_arg { -// int pipe_fd; -//}; - struct trctl_msg { /* size: the size of all the fields except size itself */ uint32_t size; @@ -121,7 +117,7 @@ static void print_markers(FILE *fp) marker_iter_start(&iter); while(iter.marker) { - fprintf(fp, "marker: %s_%s %d \"%s\"\n", iter.marker->channel, iter.marker->name, (int)imv_read(iter.marker->state), iter.marker->format); + fprintf(fp, "marker: %s/%s %d \"%s\"\n", iter.marker->channel, iter.marker->name, (int)imv_read(iter.marker->state), iter.marker->format); marker_iter_next(&iter); } unlock_markers(); @@ -772,21 +768,24 @@ void *listener_main(void *p) } } -int have_listener = 0; +volatile sig_atomic_t have_listener = 0; void create_listener(void) { #ifdef USE_CLONE static char listener_stack[16384]; + int result; #else pthread_t thread; #endif - if(have_listener) + if(have_listener) { + WARN("not creating listener because we already had one"); return; + } #ifdef USE_CLONE - result = clone(listener_main, listener_stack+sizeof(listener_stack)-1, CLONE_FS | CLONE_FILES | CLONE_VM | CLONE_SIGHAND | CLONE_THREAD, NULL); + result = clone((int (*)(void *)) listener_main, listener_stack+sizeof(listener_stack)-1, CLONE_FS | CLONE_FILES | CLONE_VM | CLONE_SIGHAND | CLONE_THREAD, NULL); if(result == -1) { perror("clone"); return; @@ -804,12 +803,10 @@ void create_listener(void) void sighandler(int sig) { - static char have_listener = 0; DBG("sighandler"); if(!have_listener) { create_listener(); - have_listener = 1; } } @@ -894,7 +891,7 @@ static void auto_probe_connect(struct marker *m) } -static void __attribute__((constructor(1000))) init() +static void __attribute__((constructor)) init() { int result; char* autoprobe_val = NULL; @@ -1008,13 +1005,15 @@ static void __attribute__((constructor(1000))) init() return; } - inform_consumer_daemon(trace_name); - result = ltt_trace_start(trace_name); if(result < 0) { ERR("ltt_trace_start failed"); return; } + + /* Do this after the trace is started in order to avoid creating confusion + * if the trace fails to start. */ + inform_consumer_daemon(trace_name); } @@ -1128,6 +1127,15 @@ static void __attribute__((destructor)) keepalive() ustcomm_fini_app(&ustcomm_app); } +void ust_potential_exec(void) +{ + trace_mark(ust, potential_exec, MARK_NOARGS); + + DBG("test"); + + keepalive(); +} + /* Notify ust that there was a fork. This needs to be called inside * the new process, anytime a process whose memory is not shared with * the parent is created. If this function is not called, the events @@ -1148,6 +1156,8 @@ void ust_fork(void) /* Delete all blocked consumers */ list_for_each_entry(bc, &blocked_consumers, list) { + close(bc->fd_producer); + close(bc->fd_consumer); free(deletable_bc); deletable_bc = bc; list_del(&bc->list);