chg: decouple hgclient from setupsignalhandler
authorJun Wu <quark@fb.com>
Mon, 02 Jan 2017 14:04:35 +0000
changeset 30690 e9ec42634ec8
parent 30689 9fa7255d4abd
child 30691 7adb60660496
chg: decouple hgclient from setupsignalhandler procutil should not depend on hgclient. This patch makes the signal handling part independent from hgclient.
contrib/chg/chg.c
contrib/chg/procutil.c
--- a/contrib/chg/chg.c	Mon Jan 02 14:02:47 2017 +0000
+++ b/contrib/chg/chg.c	Mon Jan 02 14:04:35 2017 +0000
@@ -429,7 +429,7 @@
 				 gethgcmd());
 	}
 
-	setupsignalhandler(hgc);
+	setupsignalhandler(hgc_peerpid(hgc), hgc_peerpgid(hgc));
 	pagerpid = setuppager(hgc, argv + 1, argc - 1);
 	int exitcode = hgc_runcommand(hgc, argv + 1, argc - 1);
 	restoresignalhandler();
--- a/contrib/chg/procutil.c	Mon Jan 02 14:02:47 2017 +0000
+++ b/contrib/chg/procutil.c	Mon Jan 02 14:04:35 2017 +0000
@@ -71,14 +71,11 @@
 		kill(peerpid, SIGPIPE);
 }
 
-static void setupsignalhandler(const hgclient_t *hgc)
+static void setupsignalhandler(pid_t pid, pid_t pgid)
 {
-	pid_t pid = hgc_peerpid(hgc);
 	if (pid <= 0)
 		return;
 	peerpid = pid;
-
-	pid_t pgid = hgc_peerpgid(hgc);
 	peerpgid = (pgid <= 1 ? 0 : pgid);
 
 	struct sigaction sa;