##// END OF EJS Templates
chg: enable clang-format on all .c and .h files...
Augie Fackler -
r35977:9724f549 default
parent child Browse files
Show More
@@ -38,11 +38,13 b' struct cmdserveropts {'
38 const char **args;
38 const char **args;
39 };
39 };
40
40
41 static void initcmdserveropts(struct cmdserveropts *opts) {
41 static void initcmdserveropts(struct cmdserveropts *opts)
42 {
42 memset(opts, 0, sizeof(struct cmdserveropts));
43 memset(opts, 0, sizeof(struct cmdserveropts));
43 }
44 }
44
45
45 static void freecmdserveropts(struct cmdserveropts *opts) {
46 static void freecmdserveropts(struct cmdserveropts *opts)
47 {
46 free(opts->args);
48 free(opts->args);
47 opts->args = NULL;
49 opts->args = NULL;
48 opts->argsize = 0;
50 opts->argsize = 0;
@@ -59,12 +61,8 b' static size_t testsensitiveflag(const ch'
59 const char *name;
61 const char *name;
60 size_t narg;
62 size_t narg;
61 } flags[] = {
63 } flags[] = {
62 {"--config", 1},
64 {"--config", 1}, {"--cwd", 1}, {"--repo", 1},
63 {"--cwd", 1},
65 {"--repository", 1}, {"--traceback", 0}, {"-R", 1},
64 {"--repo", 1},
65 {"--repository", 1},
66 {"--traceback", 0},
67 {"-R", 1},
68 };
66 };
69 size_t i;
67 size_t i;
70 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); ++i) {
68 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); ++i) {
@@ -89,21 +87,21 b' static size_t testsensitiveflag(const ch'
89 /*
87 /*
90 * Parse argv[] and put sensitive flags to opts->args
88 * Parse argv[] and put sensitive flags to opts->args
91 */
89 */
92 static void setcmdserverargs(struct cmdserveropts *opts,
90 static void setcmdserverargs(struct cmdserveropts *opts, int argc,
93 int argc, const char *argv[])
91 const char *argv[])
94 {
92 {
95 size_t i, step;
93 size_t i, step;
96 opts->argsize = 0;
94 opts->argsize = 0;
97 for (i = 0, step = 1; i < (size_t)argc; i += step, step = 1) {
95 for (i = 0, step = 1; i < (size_t)argc; i += step, step = 1) {
98 if (!argv[i])
96 if (!argv[i])
99 continue; /* pass clang-analyse */
97 continue; /* pass clang-analyse */
100 if (strcmp(argv[i], "--") == 0)
98 if (strcmp(argv[i], "--") == 0)
101 break;
99 break;
102 size_t n = testsensitiveflag(argv[i]);
100 size_t n = testsensitiveflag(argv[i]);
103 if (n == 0 || i + n > (size_t)argc)
101 if (n == 0 || i + n > (size_t)argc)
104 continue;
102 continue;
105 opts->args = reallocx(opts->args,
103 opts->args =
106 (n + opts->argsize) * sizeof(char *));
104 reallocx(opts->args, (n + opts->argsize) * sizeof(char *));
107 memcpy(opts->args + opts->argsize, argv + i,
105 memcpy(opts->args + opts->argsize, argv + i,
108 sizeof(char *) * n);
106 sizeof(char *) * n);
109 opts->argsize += n;
107 opts->argsize += n;
@@ -180,8 +178,8 b' static void setcmdserveropts(struct cmds'
180 r = snprintf(opts->sockname, sizeof(opts->sockname), sockfmt, basename);
178 r = snprintf(opts->sockname, sizeof(opts->sockname), sockfmt, basename);
181 if (r < 0 || (size_t)r >= sizeof(opts->sockname))
179 if (r < 0 || (size_t)r >= sizeof(opts->sockname))
182 abortmsg("too long TMPDIR or CHGSOCKNAME (r = %d)", r);
180 abortmsg("too long TMPDIR or CHGSOCKNAME (r = %d)", r);
183 r = snprintf(opts->initsockname, sizeof(opts->initsockname),
181 r = snprintf(opts->initsockname, sizeof(opts->initsockname), "%s.%u",
184 "%s.%u", opts->sockname, (unsigned)getpid());
182 opts->sockname, (unsigned)getpid());
185 if (r < 0 || (size_t)r >= sizeof(opts->initsockname))
183 if (r < 0 || (size_t)r >= sizeof(opts->initsockname))
186 abortmsg("too long TMPDIR or CHGSOCKNAME (r = %d)", r);
184 abortmsg("too long TMPDIR or CHGSOCKNAME (r = %d)", r);
187 }
185 }
@@ -208,11 +206,14 b' static void execcmdserver(const struct c'
208 const char *hgcmd = gethgcmd();
206 const char *hgcmd = gethgcmd();
209
207
210 const char *baseargv[] = {
208 const char *baseargv[] = {
211 hgcmd,
209 hgcmd,
212 "serve",
210 "serve",
213 "--cmdserver", "chgunix",
211 "--cmdserver",
214 "--address", opts->initsockname,
212 "chgunix",
215 "--daemon-postexec", "chdir:/",
213 "--address",
214 opts->initsockname,
215 "--daemon-postexec",
216 "chdir:/",
216 };
217 };
217 size_t baseargvsize = sizeof(baseargv) / sizeof(baseargv[0]);
218 size_t baseargvsize = sizeof(baseargv) / sizeof(baseargv[0]);
218 size_t argsize = baseargvsize + opts->argsize + 1;
219 size_t argsize = baseargvsize + opts->argsize + 1;
@@ -237,7 +238,7 b' static hgclient_t *retryconnectcmdserver'
237
238
238 debugmsg("try connect to %s repeatedly", opts->initsockname);
239 debugmsg("try connect to %s repeatedly", opts->initsockname);
239
240
240 unsigned int timeoutsec = 60; /* default: 60 seconds */
241 unsigned int timeoutsec = 60; /* default: 60 seconds */
241 const char *timeoutenv = getenv("CHGTIMEOUT");
242 const char *timeoutenv = getenv("CHGTIMEOUT");
242 if (timeoutenv)
243 if (timeoutenv)
243 sscanf(timeoutenv, "%u", &timeoutsec);
244 sscanf(timeoutenv, "%u", &timeoutsec);
@@ -246,7 +247,7 b' static hgclient_t *retryconnectcmdserver'
246 hgclient_t *hgc = hgc_open(opts->initsockname);
247 hgclient_t *hgc = hgc_open(opts->initsockname);
247 if (hgc) {
248 if (hgc) {
248 debugmsg("rename %s to %s", opts->initsockname,
249 debugmsg("rename %s to %s", opts->initsockname,
249 opts->sockname);
250 opts->sockname);
250 int r = rename(opts->initsockname, opts->sockname);
251 int r = rename(opts->initsockname, opts->sockname);
251 if (r != 0)
252 if (r != 0)
252 abortmsgerrno("cannot rename");
253 abortmsgerrno("cannot rename");
@@ -270,7 +271,7 b' cleanup:'
270 if (WIFEXITED(pst)) {
271 if (WIFEXITED(pst)) {
271 if (WEXITSTATUS(pst) == 0)
272 if (WEXITSTATUS(pst) == 0)
272 abortmsg("could not connect to cmdserver "
273 abortmsg("could not connect to cmdserver "
273 "(exited with status 0)");
274 "(exited with status 0)");
274 debugmsg("cmdserver exited with status %d", WEXITSTATUS(pst));
275 debugmsg("cmdserver exited with status %d", WEXITSTATUS(pst));
275 exit(WEXITSTATUS(pst));
276 exit(WEXITSTATUS(pst));
276 } else if (WIFSIGNALED(pst)) {
277 } else if (WIFSIGNALED(pst)) {
@@ -284,8 +285,8 b' cleanup:'
284 /* Connect to a cmdserver. Will start a new server on demand. */
285 /* Connect to a cmdserver. Will start a new server on demand. */
285 static hgclient_t *connectcmdserver(struct cmdserveropts *opts)
286 static hgclient_t *connectcmdserver(struct cmdserveropts *opts)
286 {
287 {
287 const char *sockname = opts->redirectsockname[0] ?
288 const char *sockname =
288 opts->redirectsockname : opts->sockname;
289 opts->redirectsockname[0] ? opts->redirectsockname : opts->sockname;
289 debugmsg("try connect to %s", sockname);
290 debugmsg("try connect to %s", sockname);
290 hgclient_t *hgc = hgc_open(sockname);
291 hgclient_t *hgc = hgc_open(sockname);
291 if (hgc)
292 if (hgc)
@@ -339,8 +340,8 b' static int runinstructions(struct cmdser'
339 unlink(*pinst + 7);
340 unlink(*pinst + 7);
340 } else if (strncmp(*pinst, "redirect ", 9) == 0) {
341 } else if (strncmp(*pinst, "redirect ", 9) == 0) {
341 int r = snprintf(opts->redirectsockname,
342 int r = snprintf(opts->redirectsockname,
342 sizeof(opts->redirectsockname),
343 sizeof(opts->redirectsockname), "%s",
343 "%s", *pinst + 9);
344 *pinst + 9);
344 if (r < 0 || r >= (int)sizeof(opts->redirectsockname))
345 if (r < 0 || r >= (int)sizeof(opts->redirectsockname))
345 abortmsg("redirect path is too long (%d)", r);
346 abortmsg("redirect path is too long (%d)", r);
346 needreconnect = 1;
347 needreconnect = 1;
@@ -365,10 +366,9 b' static int runinstructions(struct cmdser'
365 */
366 */
366 static int isunsupported(int argc, const char *argv[])
367 static int isunsupported(int argc, const char *argv[])
367 {
368 {
368 enum {
369 enum { SERVE = 1,
369 SERVE = 1,
370 DAEMON = 2,
370 DAEMON = 2,
371 SERVEDAEMON = SERVE | DAEMON,
371 SERVEDAEMON = SERVE | DAEMON,
372 };
372 };
373 unsigned int state = 0;
373 unsigned int state = 0;
374 int i;
374 int i;
@@ -378,7 +378,7 b' static int isunsupported(int argc, const'
378 if (i == 0 && strcmp("serve", argv[i]) == 0)
378 if (i == 0 && strcmp("serve", argv[i]) == 0)
379 state |= SERVE;
379 state |= SERVE;
380 else if (strcmp("-d", argv[i]) == 0 ||
380 else if (strcmp("-d", argv[i]) == 0 ||
381 strcmp("--daemon", argv[i]) == 0)
381 strcmp("--daemon", argv[i]) == 0)
382 state |= DAEMON;
382 state |= DAEMON;
383 }
383 }
384 return (state & SERVEDAEMON) == SERVEDAEMON;
384 return (state & SERVEDAEMON) == SERVEDAEMON;
@@ -401,9 +401,9 b' int main(int argc, const char *argv[], c'
401
401
402 if (getenv("CHGINTERNALMARK"))
402 if (getenv("CHGINTERNALMARK"))
403 abortmsg("chg started by chg detected.\n"
403 abortmsg("chg started by chg detected.\n"
404 "Please make sure ${HG:-hg} is not a symlink or "
404 "Please make sure ${HG:-hg} is not a symlink or "
405 "wrapper to chg. Alternatively, set $CHGHG to the "
405 "wrapper to chg. Alternatively, set $CHGHG to the "
406 "path of real hg.");
406 "path of real hg.");
407
407
408 if (isunsupported(argc - 1, argv + 1))
408 if (isunsupported(argc - 1, argv + 1))
409 execoriginalhg(argv);
409 execoriginalhg(argv);
@@ -435,11 +435,11 b' int main(int argc, const char *argv[], c'
435 hgc_close(hgc);
435 hgc_close(hgc);
436 if (++retry > 10)
436 if (++retry > 10)
437 abortmsg("too many redirections.\n"
437 abortmsg("too many redirections.\n"
438 "Please make sure %s is not a wrapper which "
438 "Please make sure %s is not a wrapper which "
439 "changes sensitive environment variables "
439 "changes sensitive environment variables "
440 "before executing hg. If you have to use a "
440 "before executing hg. If you have to use a "
441 "wrapper, wrap chg instead of hg.",
441 "wrapper, wrap chg instead of hg.",
442 gethgcmd());
442 gethgcmd());
443 }
443 }
444
444
445 setupsignalhandler(hgc_peerpid(hgc), hgc_peerpgid(hgc));
445 setupsignalhandler(hgc_peerpid(hgc), hgc_peerpgid(hgc));
@@ -7,7 +7,7 b''
7 * GNU General Public License version 2 or any later version.
7 * GNU General Public License version 2 or any later version.
8 */
8 */
9
9
10 #include <arpa/inet.h> /* for ntohl(), htonl() */
10 #include <arpa/inet.h> /* for ntohl(), htonl() */
11 #include <assert.h>
11 #include <assert.h>
12 #include <ctype.h>
12 #include <ctype.h>
13 #include <errno.h>
13 #include <errno.h>
@@ -26,16 +26,15 b''
26 #include "procutil.h"
26 #include "procutil.h"
27 #include "util.h"
27 #include "util.h"
28
28
29 enum {
29 enum { CAP_GETENCODING = 0x0001,
30 CAP_GETENCODING = 0x0001,
30 CAP_RUNCOMMAND = 0x0002,
31 CAP_RUNCOMMAND = 0x0002,
31 /* cHg extension: */
32 /* cHg extension: */
32 CAP_ATTACHIO = 0x0100,
33 CAP_ATTACHIO = 0x0100,
33 CAP_CHDIR = 0x0200,
34 CAP_CHDIR = 0x0200,
34 CAP_SETENV = 0x0800,
35 CAP_SETENV = 0x0800,
35 CAP_SETUMASK = 0x1000,
36 CAP_SETUMASK = 0x1000,
36 CAP_VALIDATE = 0x2000,
37 CAP_VALIDATE = 0x2000,
37 CAP_SETPROCNAME = 0x4000,
38 CAP_SETPROCNAME = 0x4000,
39 };
38 };
40
39
41 typedef struct {
40 typedef struct {
@@ -44,15 +43,15 b' typedef struct {'
44 } cappair_t;
43 } cappair_t;
45
44
46 static const cappair_t captable[] = {
45 static const cappair_t captable[] = {
47 {"getencoding", CAP_GETENCODING},
46 {"getencoding", CAP_GETENCODING},
48 {"runcommand", CAP_RUNCOMMAND},
47 {"runcommand", CAP_RUNCOMMAND},
49 {"attachio", CAP_ATTACHIO},
48 {"attachio", CAP_ATTACHIO},
50 {"chdir", CAP_CHDIR},
49 {"chdir", CAP_CHDIR},
51 {"setenv", CAP_SETENV},
50 {"setenv", CAP_SETENV},
52 {"setumask", CAP_SETUMASK},
51 {"setumask", CAP_SETUMASK},
53 {"validate", CAP_VALIDATE},
52 {"validate", CAP_VALIDATE},
54 {"setprocname", CAP_SETPROCNAME},
53 {"setprocname", CAP_SETPROCNAME},
55 {NULL, 0}, /* terminator */
54 {NULL, 0}, /* terminator */
56 };
55 };
57
56
58 typedef struct {
57 typedef struct {
@@ -88,8 +87,8 b' static void enlargecontext(context_t *ct'
88 if (newsize <= ctx->maxdatasize)
87 if (newsize <= ctx->maxdatasize)
89 return;
88 return;
90
89
91 newsize = defaultdatasize
90 newsize = defaultdatasize *
92 * ((newsize + defaultdatasize - 1) / defaultdatasize);
91 ((newsize + defaultdatasize - 1) / defaultdatasize);
93 ctx->data = reallocx(ctx->data, newsize);
92 ctx->data = reallocx(ctx->data, newsize);
94 ctx->maxdatasize = newsize;
93 ctx->maxdatasize = newsize;
95 debugmsg("enlarge context buffer to %zu", ctx->maxdatasize);
94 debugmsg("enlarge context buffer to %zu", ctx->maxdatasize);
@@ -126,12 +125,12 b' static void readchannel(hgclient_t *hgc)'
126 enlargecontext(&hgc->ctx, hgc->ctx.datasize);
125 enlargecontext(&hgc->ctx, hgc->ctx.datasize);
127
126
128 if (isupper(hgc->ctx.ch) && hgc->ctx.ch != 'S')
127 if (isupper(hgc->ctx.ch) && hgc->ctx.ch != 'S')
129 return; /* assumes input request */
128 return; /* assumes input request */
130
129
131 size_t cursize = 0;
130 size_t cursize = 0;
132 while (cursize < hgc->ctx.datasize) {
131 while (cursize < hgc->ctx.datasize) {
133 rsize = recv(hgc->sockfd, hgc->ctx.data + cursize,
132 rsize = recv(hgc->sockfd, hgc->ctx.data + cursize,
134 hgc->ctx.datasize - cursize, 0);
133 hgc->ctx.datasize - cursize, 0);
135 if (rsize < 1)
134 if (rsize < 1)
136 abortmsg("failed to read data block");
135 abortmsg("failed to read data block");
137 cursize += rsize;
136 cursize += rsize;
@@ -176,19 +175,19 b' static void writeblockrequest(const hgcl'
176 /* Build '\0'-separated list of args. argsize < 0 denotes that args are
175 /* Build '\0'-separated list of args. argsize < 0 denotes that args are
177 * terminated by NULL. */
176 * terminated by NULL. */
178 static void packcmdargs(context_t *ctx, const char *const args[],
177 static void packcmdargs(context_t *ctx, const char *const args[],
179 ssize_t argsize)
178 ssize_t argsize)
180 {
179 {
181 ctx->datasize = 0;
180 ctx->datasize = 0;
182 const char *const *const end = (argsize >= 0) ? args + argsize : NULL;
181 const char *const *const end = (argsize >= 0) ? args + argsize : NULL;
183 for (const char *const *it = args; it != end && *it; ++it) {
182 for (const char *const *it = args; it != end && *it; ++it) {
184 const size_t n = strlen(*it) + 1; /* include '\0' */
183 const size_t n = strlen(*it) + 1; /* include '\0' */
185 enlargecontext(ctx, ctx->datasize + n);
184 enlargecontext(ctx, ctx->datasize + n);
186 memcpy(ctx->data + ctx->datasize, *it, n);
185 memcpy(ctx->data + ctx->datasize, *it, n);
187 ctx->datasize += n;
186 ctx->datasize += n;
188 }
187 }
189
188
190 if (ctx->datasize > 0)
189 if (ctx->datasize > 0)
191 --ctx->datasize; /* strip last '\0' */
190 --ctx->datasize; /* strip last '\0' */
192 }
191 }
193
192
194 /* Extract '\0'-separated list of args to new buffer, terminated by NULL */
193 /* Extract '\0'-separated list of args to new buffer, terminated by NULL */
@@ -199,7 +198,7 b' static const char **unpackcmdargsnul(con'
199 const char *s = ctx->data;
198 const char *s = ctx->data;
200 const char *e = ctx->data + ctx->datasize;
199 const char *e = ctx->data + ctx->datasize;
201 for (;;) {
200 for (;;) {
202 if (nargs + 1 >= maxnargs) { /* including last NULL */
201 if (nargs + 1 >= maxnargs) { /* including last NULL */
203 maxnargs += 256;
202 maxnargs += 256;
204 args = reallocx(args, maxnargs * sizeof(args[0]));
203 args = reallocx(args, maxnargs * sizeof(args[0]));
205 }
204 }
@@ -237,7 +236,7 b' static void handlesystemrequest(hgclient'
237 {
236 {
238 context_t *ctx = &hgc->ctx;
237 context_t *ctx = &hgc->ctx;
239 enlargecontext(ctx, ctx->datasize + 1);
238 enlargecontext(ctx, ctx->datasize + 1);
240 ctx->data[ctx->datasize] = '\0'; /* terminate last string */
239 ctx->data[ctx->datasize] = '\0'; /* terminate last string */
241
240
242 const char **args = unpackcmdargsnul(ctx);
241 const char **args = unpackcmdargsnul(ctx);
243 if (!args[0] || !args[1] || !args[2])
242 if (!args[0] || !args[1] || !args[2])
@@ -269,8 +268,8 b' static void handleresponse(hgclient_t *h'
269 for (;;) {
268 for (;;) {
270 readchannel(hgc);
269 readchannel(hgc);
271 context_t *ctx = &hgc->ctx;
270 context_t *ctx = &hgc->ctx;
272 debugmsg("response read from channel %c, size %zu",
271 debugmsg("response read from channel %c, size %zu", ctx->ch,
273 ctx->ch, ctx->datasize);
272 ctx->datasize);
274 switch (ctx->ch) {
273 switch (ctx->ch) {
275 case 'o':
274 case 'o':
276 fwrite(ctx->data, sizeof(ctx->data[0]), ctx->datasize,
275 fwrite(ctx->data, sizeof(ctx->data[0]), ctx->datasize,
@@ -299,7 +298,7 b' static void handleresponse(hgclient_t *h'
299 default:
298 default:
300 if (isupper(ctx->ch))
299 if (isupper(ctx->ch))
301 abortmsg("cannot handle response (ch = %c)",
300 abortmsg("cannot handle response (ch = %c)",
302 ctx->ch);
301 ctx->ch);
303 }
302 }
304 }
303 }
305 }
304 }
@@ -366,8 +365,8 b' static void readhello(hgclient_t *hgc)'
366
365
367 static void updateprocname(hgclient_t *hgc)
366 static void updateprocname(hgclient_t *hgc)
368 {
367 {
369 int r = snprintf(hgc->ctx.data, hgc->ctx.maxdatasize,
368 int r = snprintf(hgc->ctx.data, hgc->ctx.maxdatasize, "chg[worker/%d]",
370 "chg[worker/%d]", (int)getpid());
369 (int)getpid());
371 if (r < 0 || (size_t)r >= hgc->ctx.maxdatasize)
370 if (r < 0 || (size_t)r >= hgc->ctx.maxdatasize)
372 abortmsg("insufficient buffer to write procname (r = %d)", r);
371 abortmsg("insufficient buffer to write procname (r = %d)", r);
373 hgc->ctx.datasize = (size_t)r;
372 hgc->ctx.datasize = (size_t)r;
@@ -387,7 +386,7 b' static void attachio(hgclient_t *hgc)'
387 static const int fds[3] = {STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO};
386 static const int fds[3] = {STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO};
388 struct msghdr msgh;
387 struct msghdr msgh;
389 memset(&msgh, 0, sizeof(msgh));
388 memset(&msgh, 0, sizeof(msgh));
390 struct iovec iov = {ctx->data, ctx->datasize}; /* dummy payload */
389 struct iovec iov = {ctx->data, ctx->datasize}; /* dummy payload */
391 msgh.msg_iov = &iov;
390 msgh.msg_iov = &iov;
392 msgh.msg_iovlen = 1;
391 msgh.msg_iovlen = 1;
393 char fdbuf[CMSG_SPACE(sizeof(fds))];
392 char fdbuf[CMSG_SPACE(sizeof(fds))];
@@ -552,7 +551,7 b' pid_t hgc_peerpid(const hgclient_t *hgc)'
552 * the last string is guaranteed to be NULL.
551 * the last string is guaranteed to be NULL.
553 */
552 */
554 const char **hgc_validate(hgclient_t *hgc, const char *const args[],
553 const char **hgc_validate(hgclient_t *hgc, const char *const args[],
555 size_t argsize)
554 size_t argsize)
556 {
555 {
557 assert(hgc);
556 assert(hgc);
558 if (!(hgc->capflags & CAP_VALIDATE))
557 if (!(hgc->capflags & CAP_VALIDATE))
@@ -22,9 +22,9 b' pid_t hgc_peerpgid(const hgclient_t *hgc'
22 pid_t hgc_peerpid(const hgclient_t *hgc);
22 pid_t hgc_peerpid(const hgclient_t *hgc);
23
23
24 const char **hgc_validate(hgclient_t *hgc, const char *const args[],
24 const char **hgc_validate(hgclient_t *hgc, const char *const args[],
25 size_t argsize);
25 size_t argsize);
26 int hgc_runcommand(hgclient_t *hgc, const char *const args[], size_t argsize);
26 int hgc_runcommand(hgclient_t *hgc, const char *const args[], size_t argsize);
27 void hgc_attachio(hgclient_t *hgc);
27 void hgc_attachio(hgclient_t *hgc);
28 void hgc_setenv(hgclient_t *hgc, const char *const envp[]);
28 void hgc_setenv(hgclient_t *hgc, const char *const envp[]);
29
29
30 #endif /* HGCLIENT_H_ */
30 #endif /* HGCLIENT_H_ */
@@ -54,7 +54,7 b' static void handlestopsignal(int sig)'
54 goto error;
54 goto error;
55
55
56 forwardsignal(sig);
56 forwardsignal(sig);
57 if (raise(sig) < 0) /* resend to self */
57 if (raise(sig) < 0) /* resend to self */
58 goto error;
58 goto error;
59 if (sigaction(sig, &sa, &oldsa) < 0)
59 if (sigaction(sig, &sa, &oldsa) < 0)
60 goto error;
60 goto error;
@@ -205,8 +205,8 b' pid_t setuppager(const char *pagercmd, c'
205 close(pipefds[0]);
205 close(pipefds[0]);
206 close(pipefds[1]);
206 close(pipefds[1]);
207
207
208 int r = execle("/bin/sh", "/bin/sh", "-c", pagercmd, NULL,
208 int r =
209 envp);
209 execle("/bin/sh", "/bin/sh", "-c", pagercmd, NULL, envp);
210 if (r < 0) {
210 if (r < 0) {
211 abortmsgerrno("cannot start pager '%s'", pagercmd);
211 abortmsgerrno("cannot start pager '%s'", pagercmd);
212 }
212 }
@@ -62,7 +62,8 b' void abortmsgerrno(const char *fmt, ...)'
62 static int debugmsgenabled = 0;
62 static int debugmsgenabled = 0;
63 static double debugstart = 0;
63 static double debugstart = 0;
64
64
65 static double now() {
65 static double now()
66 {
66 struct timeval t;
67 struct timeval t;
67 gettimeofday(&t, NULL);
68 gettimeofday(&t, NULL);
68 return t.tv_usec / 1e6 + t.tv_sec;
69 return t.tv_usec / 1e6 + t.tv_sec;
@@ -32,4 +32,4 b' void *reallocx(void *ptr, size_t size);'
32
32
33 int runshellcmd(const char *cmd, const char *envp[], const char *cwd);
33 int runshellcmd(const char *cmd, const char *envp[], const char *cwd);
34
34
35 #endif /* UTIL_H_ */
35 #endif /* UTIL_H_ */
@@ -1,12 +1,5 b''
1 # Files that just need to be migrated to the formatter.
1 # Files that just need to be migrated to the formatter.
2 # Do not add new files here!
2 # Do not add new files here!
3 contrib/chg/chg.c
4 contrib/chg/hgclient.c
5 contrib/chg/hgclient.h
6 contrib/chg/procutil.c
7 contrib/chg/procutil.h
8 contrib/chg/util.c
9 contrib/chg/util.h
10 contrib/hgsh/hgsh.c
3 contrib/hgsh/hgsh.c
11 mercurial/cext/base85.c
4 mercurial/cext/base85.c
12 mercurial/cext/bdiff.c
5 mercurial/cext/bdiff.c
General Comments 0
You need to be logged in to leave comments. Login now