##// END OF EJS Templates
chg: replace abortmsg showing errno with abortmsgerrno...
Jun Wu -
r28789:7f6e0a15 default
parent child Browse files
Show More
@@ -114,13 +114,12 b' static void preparesockdir(const char *s'
114 int r;
114 int r;
115 r = mkdir(sockdir, 0700);
115 r = mkdir(sockdir, 0700);
116 if (r < 0 && errno != EEXIST)
116 if (r < 0 && errno != EEXIST)
117 abortmsg("cannot create sockdir %s (errno = %d)",
117 abortmsgerrno("cannot create sockdir %s", sockdir);
118 sockdir, errno);
119
118
120 struct stat st;
119 struct stat st;
121 r = lstat(sockdir, &st);
120 r = lstat(sockdir, &st);
122 if (r < 0)
121 if (r < 0)
123 abortmsg("cannot stat %s (errno = %d)", sockdir, errno);
122 abortmsgerrno("cannot stat %s", sockdir);
124 if (!S_ISDIR(st.st_mode))
123 if (!S_ISDIR(st.st_mode))
125 abortmsg("cannot create sockdir %s (file exists)", sockdir);
124 abortmsg("cannot create sockdir %s (file exists)", sockdir);
126 if (st.st_uid != geteuid() || st.st_mode & 0077)
125 if (st.st_uid != geteuid() || st.st_mode & 0077)
@@ -166,11 +165,12 b' static void lockcmdserver(struct cmdserv'
166 if (opts->lockfd == -1) {
165 if (opts->lockfd == -1) {
167 opts->lockfd = open(opts->lockfile, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
166 opts->lockfd = open(opts->lockfile, O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
168 if (opts->lockfd == -1)
167 if (opts->lockfd == -1)
169 abortmsg("cannot create lock file %s", opts->lockfile);
168 abortmsgerrno("cannot create lock file %s",
169 opts->lockfile);
170 }
170 }
171 int r = flock(opts->lockfd, LOCK_EX);
171 int r = flock(opts->lockfd, LOCK_EX);
172 if (r == -1)
172 if (r == -1)
173 abortmsg("cannot acquire lock");
173 abortmsgerrno("cannot acquire lock");
174 }
174 }
175
175
176 /*
176 /*
@@ -224,9 +224,9 b' static void execcmdserver(const struct c'
224 argv[argsize - 1] = NULL;
224 argv[argsize - 1] = NULL;
225
225
226 if (putenv("CHGINTERNALMARK=") != 0)
226 if (putenv("CHGINTERNALMARK=") != 0)
227 abortmsg("failed to putenv (errno = %d)", errno);
227 abortmsgerrno("failed to putenv");
228 if (execvp(hgcmd, (char **)argv) < 0)
228 if (execvp(hgcmd, (char **)argv) < 0)
229 abortmsg("failed to exec cmdserver (errno = %d)", errno);
229 abortmsgerrno("failed to exec cmdserver");
230 free(argv);
230 free(argv);
231 }
231 }
232
232
@@ -325,7 +325,7 b' static void forwardsignal(int sig)'
325 {
325 {
326 assert(peerpid > 0);
326 assert(peerpid > 0);
327 if (kill(peerpid, sig) < 0)
327 if (kill(peerpid, sig) < 0)
328 abortmsg("cannot kill %d (errno = %d)", peerpid, errno);
328 abortmsgerrno("cannot kill %d", peerpid);
329 debugmsg("forward signal %d", sig);
329 debugmsg("forward signal %d", sig);
330 }
330 }
331
331
@@ -358,7 +358,7 b' static void handlestopsignal(int sig)'
358 return;
358 return;
359
359
360 error:
360 error:
361 abortmsg("failed to handle stop signal (errno = %d)", errno);
361 abortmsgerrno("failed to handle stop signal");
362 }
362 }
363
363
364 static void setupsignalhandler(pid_t pid)
364 static void setupsignalhandler(pid_t pid)
@@ -397,7 +397,7 b' static void setupsignalhandler(pid_t pid'
397 return;
397 return;
398
398
399 error:
399 error:
400 abortmsg("failed to set up signal handlers (errno = %d)", errno);
400 abortmsgerrno("failed to set up signal handlers");
401 }
401 }
402
402
403 /* This implementation is based on hgext/pager.py (pre 369741ef7253) */
403 /* This implementation is based on hgext/pager.py (pre 369741ef7253) */
@@ -432,8 +432,7 b' static void setuppager(hgclient_t *hgc, '
432
432
433 int r = execlp("/bin/sh", "/bin/sh", "-c", pagercmd, NULL);
433 int r = execlp("/bin/sh", "/bin/sh", "-c", pagercmd, NULL);
434 if (r < 0) {
434 if (r < 0) {
435 abortmsg("cannot start pager '%s' (errno = %d)",
435 abortmsgerrno("cannot start pager '%s'", pagercmd);
436 pagercmd, errno);
437 }
436 }
438 return;
437 return;
439 }
438 }
@@ -441,7 +440,7 b' static void setuppager(hgclient_t *hgc, '
441 error:
440 error:
442 close(pipefds[0]);
441 close(pipefds[0]);
443 close(pipefds[1]);
442 close(pipefds[1]);
444 abortmsg("failed to prepare pager (errno = %d)", errno);
443 abortmsgerrno("failed to prepare pager");
445 }
444 }
446
445
447 /* Run instructions sent from the server like unlink and set redirect path
446 /* Run instructions sent from the server like unlink and set redirect path
@@ -514,7 +513,7 b' static void execoriginalhg(const char *a'
514 {
513 {
515 debugmsg("execute original hg");
514 debugmsg("execute original hg");
516 if (execvp(gethgcmd(), (char **)argv) < 0)
515 if (execvp(gethgcmd(), (char **)argv) < 0)
517 abortmsg("failed to exec original hg (errno = %d)", errno);
516 abortmsgerrno("failed to exec original hg");
518 }
517 }
519
518
520 int main(int argc, const char *argv[], const char *envp[])
519 int main(int argc, const char *argv[], const char *envp[])
@@ -141,7 +141,7 b' static void sendall(int sockfd, const vo'
141 while (p < endp) {
141 while (p < endp) {
142 ssize_t r = send(sockfd, p, endp - p, 0);
142 ssize_t r = send(sockfd, p, endp - p, 0);
143 if (r < 0)
143 if (r < 0)
144 abortmsg("cannot communicate (errno = %d)", errno);
144 abortmsgerrno("cannot communicate");
145 p += r;
145 p += r;
146 }
146 }
147 }
147 }
@@ -374,7 +374,7 b' static void attachio(hgclient_t *hgc)'
374 msgh.msg_controllen = cmsg->cmsg_len;
374 msgh.msg_controllen = cmsg->cmsg_len;
375 ssize_t r = sendmsg(hgc->sockfd, &msgh, 0);
375 ssize_t r = sendmsg(hgc->sockfd, &msgh, 0);
376 if (r < 0)
376 if (r < 0)
377 abortmsg("sendmsg failed (errno = %d)", errno);
377 abortmsgerrno("sendmsg failed");
378
378
379 handleresponse(hgc);
379 handleresponse(hgc);
380 int32_t n;
380 int32_t n;
@@ -389,7 +389,7 b' static void attachio(hgclient_t *hgc)'
389 static void chdirtocwd(hgclient_t *hgc)
389 static void chdirtocwd(hgclient_t *hgc)
390 {
390 {
391 if (!getcwd(hgc->ctx.data, hgc->ctx.maxdatasize))
391 if (!getcwd(hgc->ctx.data, hgc->ctx.maxdatasize))
392 abortmsg("failed to getcwd (errno = %d)", errno);
392 abortmsgerrno("failed to getcwd");
393 hgc->ctx.datasize = strlen(hgc->ctx.data);
393 hgc->ctx.datasize = strlen(hgc->ctx.data);
394 writeblockrequest(hgc, "chdir");
394 writeblockrequest(hgc, "chdir");
395 }
395 }
@@ -414,15 +414,15 b' hgclient_t *hgc_open(const char *socknam'
414 {
414 {
415 int fd = socket(AF_UNIX, SOCK_STREAM, 0);
415 int fd = socket(AF_UNIX, SOCK_STREAM, 0);
416 if (fd < 0)
416 if (fd < 0)
417 abortmsg("cannot create socket (errno = %d)", errno);
417 abortmsgerrno("cannot create socket");
418
418
419 /* don't keep fd on fork(), so that it can be closed when the parent
419 /* don't keep fd on fork(), so that it can be closed when the parent
420 * process get terminated. */
420 * process get terminated. */
421 int flags = fcntl(fd, F_GETFD);
421 int flags = fcntl(fd, F_GETFD);
422 if (flags < 0)
422 if (flags < 0)
423 abortmsg("cannot get flags of socket (errno = %d)", errno);
423 abortmsgerrno("cannot get flags of socket");
424 if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0)
424 if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0)
425 abortmsg("cannot set flags of socket (errno = %d)", errno);
425 abortmsgerrno("cannot set flags of socket");
426
426
427 struct sockaddr_un addr;
427 struct sockaddr_un addr;
428 addr.sun_family = AF_UNIX;
428 addr.sun_family = AF_UNIX;
@@ -434,8 +434,7 b' hgclient_t *hgc_open(const char *socknam'
434 close(fd);
434 close(fd);
435 if (errno == ENOENT || errno == ECONNREFUSED)
435 if (errno == ENOENT || errno == ECONNREFUSED)
436 return NULL;
436 return NULL;
437 abortmsg("cannot connect to %s (errno = %d)",
437 abortmsgerrno("cannot connect to %s", addr.sun_path);
438 addr.sun_path, errno);
439 }
438 }
440 debugmsg("connected to %s", addr.sun_path);
439 debugmsg("connected to %s", addr.sun_path);
441
440
General Comments 0
You need to be logged in to leave comments. Login now