Mercurial > hg-stable
comparison contrib/chg/util.c @ 28854:ddef14468952
chg: add fchdirx as a utility function
As part of the series to support long socket paths, we need to use fchdir and
check its result in several places. Make it a utility function.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sun, 10 Apr 2016 03:14:32 +0100 |
parents | 57a78a64de44 |
children | f5764e177bbe |
comparison
equal
deleted
inserted
replaced
28853:d11548b4ae45 | 28854:ddef14468952 |
---|---|
80 fputs("chg: debug: ", stderr); | 80 fputs("chg: debug: ", stderr); |
81 vfprintf(stderr, fmt, args); | 81 vfprintf(stderr, fmt, args); |
82 fsetcolor(stderr, ""); | 82 fsetcolor(stderr, ""); |
83 fputc('\n', stderr); | 83 fputc('\n', stderr); |
84 va_end(args); | 84 va_end(args); |
85 } | |
86 | |
87 void fchdirx(int dirfd) | |
88 { | |
89 int r = fchdir(dirfd); | |
90 if (r == -1) | |
91 abortmsgerrno("failed to fchdir"); | |
85 } | 92 } |
86 | 93 |
87 void *mallocx(size_t size) | 94 void *mallocx(size_t size) |
88 { | 95 { |
89 void *result = malloc(size); | 96 void *result = malloc(size); |