# HG changeset patch # User Jun Wu # Date 1483369034 0 # Node ID baee0f47b53313e81866c18dd9f740fe52eb3300 # Parent 23ddd43ba866422944eaeeadfd26485b9a3e1d39 chg: add procutil.h This patch adds a formal header procutil.h for procutil.c, and changes Makefile to build procutil.c independently. diff -r 23ddd43ba866 -r baee0f47b533 contrib/chg/Makefile --- a/contrib/chg/Makefile Mon Jan 02 14:43:37 2017 +0000 +++ b/contrib/chg/Makefile Mon Jan 02 14:57:14 2017 +0000 @@ -1,7 +1,7 @@ HG = $(CURDIR)/../../hg TARGET = chg -SRCS = chg.c hgclient.c util.c +SRCS = chg.c hgclient.c procutil.c util.c OBJS = $(SRCS:.c=.o) CFLAGS ?= -O2 -Wall -Wextra -pedantic -g @@ -24,8 +24,9 @@ $(TARGET): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) -chg.o: hgclient.h util.h +chg.o: hgclient.h procutil.h util.h hgclient.o: hgclient.h util.h +procutil.o: procutil.h util.h util.o: util.h .PHONY: install diff -r 23ddd43ba866 -r baee0f47b533 contrib/chg/chg.c --- a/contrib/chg/chg.c Mon Jan 02 14:43:37 2017 +0000 +++ b/contrib/chg/chg.c Mon Jan 02 14:57:14 2017 +0000 @@ -23,6 +23,7 @@ #include #include "hgclient.h" +#include "procutil.h" #include "util.h" #ifndef PATH_MAX @@ -303,8 +304,6 @@ } } -#include "procutil.c" - /* Run instructions sent from the server like unlink and set redirect path * Return 1 if reconnect is needed, otherwise 0 */ static int runinstructions(struct cmdserveropts *opts, const char **insts) diff -r 23ddd43ba866 -r baee0f47b533 contrib/chg/procutil.c --- a/contrib/chg/procutil.c Mon Jan 02 14:43:37 2017 +0000 +++ b/contrib/chg/procutil.c Mon Jan 02 14:57:14 2017 +0000 @@ -7,6 +7,17 @@ * GNU General Public License version 2 or any later version. */ +#include +#include +#include +#include +#include +#include +#include + +#include "procutil.h" +#include "util.h" + static pid_t pagerpid = 0; static pid_t peerpgid = 0; static pid_t peerpid = 0; @@ -71,7 +82,7 @@ kill(peerpid, SIGPIPE); } -static void setupsignalhandler(pid_t pid, pid_t pgid) +void setupsignalhandler(pid_t pid, pid_t pgid) { if (pid <= 0) return; @@ -121,7 +132,7 @@ abortmsgerrno("failed to set up signal handlers"); } -static void restoresignalhandler() +void restoresignalhandler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); @@ -157,7 +168,7 @@ /* This implementation is based on hgext/pager.py (post 369741ef7253) * Return 0 if pager is not started, or pid of the pager */ -static pid_t setuppager(const char *pagercmd) +pid_t setuppager(const char *pagercmd) { assert(pagerpid == 0); if (!pagercmd) @@ -199,7 +210,7 @@ return 0; } -static void waitpager(void) +void waitpager(void) { if (pagerpid == 0) return; diff -r 23ddd43ba866 -r baee0f47b533 contrib/chg/procutil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/chg/procutil.h Mon Jan 02 14:57:14 2017 +0000 @@ -0,0 +1,21 @@ +/* + * Utilities about process handling - signal and subprocess (ex. pager) + * + * Copyright (c) 2011 Yuya Nishihara + * + * This software may be used and distributed according to the terms of the + * GNU General Public License version 2 or any later version. + */ + +#ifndef PROCUTIL_H_ +#define PROCUTIL_H_ + +#include + +void restoresignalhandler(void); +void setupsignalhandler(pid_t pid, pid_t pgid); + +pid_t setuppager(const char *pagercmd); +void waitpager(void); + +#endif /* PROCUTIL_H_ */