[sysprof] Ignore fork events that are just new threads being spawned.



commit 2d5cf4c93fe7d57f797a74513e24aeabe776f636
Author: Søren Sandmann Pedersen <sandmann daimi au dk>
Date:   Wed Mar 10 06:58:22 2010 -0500

    Ignore fork events that are just new threads being spawned.
    
    These would cause mysterious new processes to show up.

 collector.c |    2 +-
 tracker.c   |   13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/collector.c b/collector.c
index 438b920..1c7af11 100644
--- a/collector.c
+++ b/collector.c
@@ -574,7 +574,7 @@ process_comm (Collector *collector, comm_event_t *comm)
 static void
 process_fork (Collector *collector, fork_event_t *fork)
 {
-    d_print ("ppid: %d  pid: %d   ptid: %d  tid %d",
+    g_print ("ppid: %d  pid: %d   ptid: %d  tid %d\n",
 	     fork->ppid, fork->pid, fork->ptid, fork->tid);
     
     tracker_add_fork (collector->tracker, fork->ppid, fork->pid);
diff --git a/tracker.c b/tracker.c
index c7427b8..90fa26b 100644
--- a/tracker.c
+++ b/tracker.c
@@ -493,6 +493,12 @@ process_fork (state_t *state, fork_t *fork)
     process_t *parent = g_hash_table_lookup (
 	state->processes_by_pid, GINT_TO_POINTER (GET_PID (fork->header)));
 
+    if (GET_PID (fork->header) == fork->child_pid)
+    {
+	/* Just a new thread being spawned */
+	return;
+    }
+    
 #if 0
     if (parent)
 #endif
@@ -505,7 +511,12 @@ process_fork (state_t *state, fork_t *fork)
 #endif
 
 	process->pid = fork->child_pid;
-	process->comm = g_strdup (parent? parent->comm : "<unknown>");
+
+	if (parent)
+	    process->comm = g_strdup (parent->comm);
+	else
+	    process->comm = g_strdup_printf ("<pid %d>", fork->child_pid);
+
 	process->maps = g_ptr_array_new ();
 
 	if (parent)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]