diff contrib/chg/hgclient.c @ 29581:c66bc06f1bf6

chg: add pgid to hgclient struct The previous patch makes the server tell the client its pgid. This patch stores it in hgclient_t and adds a function to get it.
author Jun Wu <quark@fb.com>
date Sun, 17 Jul 2016 23:05:59 +0100
parents f5764e177bbe
children 4fc4b8cc9957
line wrap: on
line diff
--- a/contrib/chg/hgclient.c	Sun Jul 17 22:56:05 2016 +0100
+++ b/contrib/chg/hgclient.c	Sun Jul 17 23:05:59 2016 +0100
@@ -63,6 +63,7 @@
 
 struct hgclient_tag_ {
 	int sockfd;
+	pid_t pgid;
 	pid_t pid;
 	context_t ctx;
 	unsigned int capflags;
@@ -339,6 +340,8 @@
 			u = dataend;
 		if (strncmp(s, "capabilities:", t - s + 1) == 0) {
 			hgc->capflags = parsecapabilities(t + 2, u);
+		} else if (strncmp(s, "pgid:", t - s + 1) == 0) {
+			hgc->pgid = strtol(t + 2, NULL, 10);
 		} else if (strncmp(s, "pid:", t - s + 1) == 0) {
 			hgc->pid = strtol(t + 2, NULL, 10);
 		}
@@ -463,6 +466,12 @@
 	free(hgc);
 }
 
+pid_t hgc_peerpgid(const hgclient_t *hgc)
+{
+	assert(hgc);
+	return hgc->pgid;
+}
+
 pid_t hgc_peerpid(const hgclient_t *hgc)
 {
 	assert(hgc);