[PATCH 3 of 3] chg: forward SIGINT, SIGHUP to process group
Jun Wu
quark at fb.com
Sun Jul 17 18:39:54 EDT 2016
Excerpts from Jun Wu's message of 2016-07-17 23:09:43 +0100:
> -static void setupsignalhandler(pid_t pid)
> +static void setupsignalhandler(const hgclient_t *hgc)
> {
> - if (pid <= 0)
> + peerpgid = hgc_peerpgid(hgc);
> + peerpid = hgc_peerpid(hgc);
I noticed this changed behavior a bit as I pursued short code: the second
setupsignalhandler call (if exists) becomes unsafe and the if condition is
not quite right. It's probably better not to save lines:
diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -404,10 +404,14 @@ static void handlechildsignal(int sig UN
static void setupsignalhandler(const hgclient_t *hgc)
{
- peerpgid = hgc_peerpgid(hgc);
- peerpid = hgc_peerpid(hgc);
- if (peerpgid <= 0 && peerpid <= 0)
+ pid_t pid = hgc_peerpid(hgc);
+ if (pid <= 0)
return;
+ pid_t pgid = hgc_peerpgid(hgc);
+ if (pgid < 0)
+ pgid = 0;
+ peerpid = pid;
+ peerpgid = pgid;
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
More information about the Mercurial-devel
mailing list