Skip to content

Commit 5816cc7

Browse files
committed
Merge branch 'dg/run-command-child-cleanup'
The code to wait for subprocess and remove it from our internal queue wasn't quite right. * dg/run-command-child-cleanup: run-command.c: fix broken list iteration in clear_child_for_cleanup
2 parents cd14f3e + bdee397 commit 5816cc7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

run-command.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@ static void mark_child_for_cleanup(pid_t pid)
5353

5454
static void clear_child_for_cleanup(pid_t pid)
5555
{
56-
struct child_to_clean **last, *p;
56+
struct child_to_clean **pp;
5757

58-
last = &children_to_clean;
59-
for (p = children_to_clean; p; p = p->next) {
60-
if (p->pid == pid) {
61-
*last = p->next;
62-
free(p);
58+
for (pp = &children_to_clean; *pp; pp = &(*pp)->next) {
59+
struct child_to_clean *clean_me = *pp;
60+
61+
if (clean_me->pid == pid) {
62+
*pp = clean_me->next;
63+
free(clean_me);
6364
return;
6465
}
6566
}

0 commit comments

Comments
 (0)