Skip to content

Commit a15bcaf

Browse files
Łukasz Stelmachbluca
authored andcommitted
Keep working with PID#1
Do not skip the first sample for PID#1 The continue statement was introduced very early with commit 5da71e1 in the original reposiotory before bootchart was merged into systemd, when there was little code at the end of the while loop and apparently skipping it didn't hurt. Specifically commit 9b004a7 introduces still_runnig flag which is never set for PID#1 which makes it subject to garbage collection in garbage_collect_dead_processes().
1 parent 6fbc82c commit a15bcaf

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/store.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -356,37 +356,37 @@ int log_sample(DIR *proc,
356356
* these are used to paint the tree coherently later
357357
* each parent has a LL of children, and a LL of siblings
358358
*/
359-
if (pid == 1)
360-
continue; /* nothing to do for init atm */
361-
362-
/* kthreadd has ppid=0, which breaks our tree ordering */
363-
if (ps->ppid == 0)
364-
ps->ppid = 1;
365-
366-
parent = ps_first;
367-
while ((parent->next_ps && parent->pid != ps->ppid))
368-
parent = parent->next_ps;
369-
370-
if (parent->pid != ps->ppid) {
371-
/* orphan */
372-
ps->ppid = 1;
373-
parent = ps_first->next_ps;
374-
}
375-
376-
ps->parent = parent;
377-
378-
/*
379-
* append ourselves to the list of children
380-
* TODO: consider if prepending is OK for efficiency here.
381-
*/
382-
{
383-
struct ps_struct **children = &parent->children;
384-
while (*children)
385-
children = &(*children)->next;
386-
*children = ps;
359+
if (pid != 1) {
360+
/* nothing to do for init atm */
361+
362+
/* kthreadd has ppid=0, which breaks our tree ordering */
363+
if (ps->ppid == 0)
364+
ps->ppid = 1;
365+
366+
parent = ps_first;
367+
while ((parent->next_ps && parent->pid != ps->ppid))
368+
parent = parent->next_ps;
369+
370+
if (parent->pid != ps->ppid) {
371+
/* orphan */
372+
ps->ppid = 1;
373+
parent = ps_first->next_ps;
374+
}
375+
376+
ps->parent = parent;
377+
378+
/*
379+
* append ourselves to the list of children
380+
* TODO: consider if prepending is OK for efficiency here.
381+
*/
382+
{
383+
struct ps_struct **children = &parent->children;
384+
while (*children)
385+
children = &(*children)->next;
386+
*children = ps;
387+
}
387388
}
388389
}
389-
390390
/* else -> found pid, append data in ps */
391391

392392
/* below here is all continuous logging parts - we get here on every

0 commit comments

Comments
 (0)