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 <nils.carlson@ericsson.com>
Acked-by: David Goulet <david.goulet@polymtl.ca>
+/* 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];
static struct ustcomm_header _receive_header;
static struct ustcomm_header *receive_header = &_receive_header;
static char receive_buffer[USTCOMM_BUFFER_SIZE];
* pid, (before and after an exec).
*/
pidunique = make_pidunique();
* pid, (before and after an exec).
*/
pidunique = make_pidunique();
DBG("Tracectl constructor");
DBG("Tracectl constructor");
static void __attribute__((destructor)) keepalive()
{
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...");
if (trace_recording() && LOAD_SHARED(buffers_to_export)) {
int total = 0;
DBG("Keeping process alive for consumer daemon...");
/* FIXME: technically, the locks could have been taken before the fork */
DBG("ust: forking");
/* 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();
/* break lock if necessary */
ltt_unlock_traces();