# HG changeset patch # User Jun Wu # Date 2016-07-17 22:05:59 # Node ID c66bc06f1bf6f01124dcf24c2934398a0c1d2bde # Parent ee8186457516ed1341db5fdfd9cd98bac6db99d0 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. diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c --- a/contrib/chg/hgclient.c +++ b/contrib/chg/hgclient.c @@ -63,6 +63,7 @@ typedef struct { struct hgclient_tag_ { int sockfd; + pid_t pgid; pid_t pid; context_t ctx; unsigned int capflags; @@ -339,6 +340,8 @@ static void readhello(hgclient_t *hgc) 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 @@ void hgc_close(hgclient_t *hgc) 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); diff --git a/contrib/chg/hgclient.h b/contrib/chg/hgclient.h --- a/contrib/chg/hgclient.h +++ b/contrib/chg/hgclient.h @@ -18,6 +18,7 @@ typedef struct hgclient_tag_ hgclient_t; 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[],