From: Nils Carlson Date: Mon, 25 Oct 2010 10:57:30 +0000 (+0200) Subject: Make tracectl destructor aware of fork status X-Git-Tag: v0.8~1 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bc237fab2306223e429c43ff003ac06c3777be99;p=ust.git Make tracectl destructor aware of fork status This little patch checks to see whether we have used a fork wrapper to fork. If not we won't have a working UST in the process and can skip the destructor stage. Signed-off-by: Nils Carlson Acked-by: David Goulet --- diff --git a/libust/tracectl.c b/libust/tracectl.c index 3d09cc2..5f942cd 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -50,6 +50,12 @@ */ s64 pidunique = -1LL; +/* The process pid is used to detect a non-traceable fork + * and allow the non-traceable fork to be ignored + * by destructor sequences in libust + */ +static pid_t processpid = 0; + static struct ustcomm_header _receive_header; static struct ustcomm_header *receive_header = &_receive_header; static char receive_buffer[USTCOMM_BUFFER_SIZE]; @@ -1201,6 +1207,7 @@ static void __attribute__((constructor)) init() * pid, (before and after an exec). */ pidunique = make_pidunique(); + processpid = getpid(); DBG("Tracectl constructor"); @@ -1466,6 +1473,10 @@ static void stop_listener(void) static void __attribute__((destructor)) keepalive() { + if (processpid != getpid()) { + return; + } + if (trace_recording() && LOAD_SHARED(buffers_to_export)) { int total = 0; DBG("Keeping process alive for consumer daemon..."); @@ -1516,6 +1527,9 @@ static void ust_fork(void) /* FIXME: technically, the locks could have been taken before the fork */ DBG("ust: forking"); + /* Get the pid of the new process */ + processpid = getpid(); + /* break lock if necessary */ ltt_unlock_traces();