Skip to content

Commit cd409c5

Browse files
committed
run-command: use cleanup api for parallel_processes
The existing code is kind of sketchy here, and could probably use some cleanups to fix the questions raised in comments.
1 parent 1d39faf commit cd409c5

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

run-command.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,9 +1541,9 @@ static struct parallel_processes_for_signal *pp_for_signal;
15411541

15421542
static void handle_children_on_signal(int signo)
15431543
{
1544+
if (!pp_for_signal)
1545+
return;
15441546
kill_children_signal(pp_for_signal, signo);
1545-
sigchain_pop(signo);
1546-
raise(signo);
15471547
}
15481548

15491549
static void pp_init(struct parallel_processes *pp,
@@ -1577,7 +1577,8 @@ static void pp_init(struct parallel_processes *pp,
15771577
pp_sig->pp = pp;
15781578
pp_sig->opts = opts;
15791579
pp_for_signal = pp_sig;
1580-
sigchain_push_common(handle_children_on_signal);
1580+
/* XXX should be idempotent */
1581+
cleanup_register(handle_children_on_signal);
15811582
}
15821583

15831584
static void pp_cleanup(struct parallel_processes *pp,
@@ -1599,7 +1600,9 @@ static void pp_cleanup(struct parallel_processes *pp,
15991600
strbuf_write(&pp->buffered_output, stderr);
16001601
strbuf_release(&pp->buffered_output);
16011602

1602-
sigchain_pop_common();
1603+
/* should this be at the top? We are putting pp into a broken state */
1604+
/* should this be a stack or list that restores the previous entry? */
1605+
pp_for_signal = NULL;
16031606
}
16041607

16051608
/* returns

0 commit comments

Comments
 (0)