Patchwork [2,of,5] chg: decouple hgclient from setupsignalhandler

login
register
mail settings
Submitter Jun Wu
Date Jan. 2, 2017, 3:09 p.m.
Message ID <a8f21835ad4f31aa1c34.1483369764@x1c>
Download mbox | patch
Permalink /patch/18063/
State Accepted
Headers show

Comments

Jun Wu - Jan. 2, 2017, 3:09 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1483365875 0
#      Mon Jan 02 14:04:35 2017 +0000
# Node ID a8f21835ad4f31aa1c34f7f3eadb0f2a147af6bd
# Parent  b7b0802884d85cbfb7ebf5bab6c590fe72ec6347
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r a8f21835ad4f
chg: decouple hgclient from setupsignalhandler

procutil should not depend on hgclient. This patch makes the signal handling
part independent from hgclient.

Patch

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -430,5 +430,5 @@  int main(int argc, const char *argv[], c
 	}
 
-	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);
diff --git a/contrib/chg/procutil.c b/contrib/chg/procutil.c
--- a/contrib/chg/procutil.c
+++ b/contrib/chg/procutil.c
@@ -72,12 +72,9 @@  static void handlechildsignal(int sig UN
 }
 
-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);