changeset 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 ee8186457516
children ee96d95e81a4
files contrib/chg/hgclient.c contrib/chg/hgclient.h
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
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);
--- a/contrib/chg/hgclient.h	Sun Jul 17 22:56:05 2016 +0100
+++ b/contrib/chg/hgclient.h	Sun Jul 17 23:05:59 2016 +0100
@@ -18,6 +18,7 @@
 hgclient_t *hgc_open(const char *sockname);
 void hgc_close(hgclient_t *hgc);
 
+pid_t hgc_peerpgid(const hgclient_t *hgc);
 pid_t hgc_peerpid(const hgclient_t *hgc);
 
 const char **hgc_validate(hgclient_t *hgc, const char *const args[],