aboutsummaryrefslogtreecommitdiff
path: root/runit
diff options
context:
space:
mode:
authorGravatar Denis Vlasenko <vda.linux@googlemail.com>2007-09-30 23:50:48 +0000
committerGravatar Denis Vlasenko <vda.linux@googlemail.com>2007-09-30 23:50:48 +0000
commit96e1b38586e80a0f014038bf4fdf4689c668fbd6 (patch)
treed7f6a7866700601598cfcc006b7dcb6cb4a7c07e /runit
parentdeabacdf91c6d1c3cfcdb4cd06780807193de81d (diff)
downloadbusybox-96e1b38586e80a0f014038bf4fdf4689c668fbd6.tar.gz
busybox-96e1b38586e80a0f014038bf4fdf4689c668fbd6.tar.bz2
introduce and use close_on_exec_on(fd). -50 bytes.
Diffstat (limited to 'runit')
-rw-r--r--runit/runit_lib.c5
-rw-r--r--runit/runit_lib.h2
-rw-r--r--runit/runsv.c24
-rw-r--r--runit/runsvdir.c6
-rw-r--r--runit/svlogd.c10
5 files changed, 20 insertions, 27 deletions
diff --git a/runit/runit_lib.c b/runit/runit_lib.c
index 4b7950ca3..2ed9054fd 100644
--- a/runit/runit_lib.c
+++ b/runit/runit_lib.c
@@ -50,11 +50,6 @@ unsigned byte_chr(char *s,unsigned n,int c)
return t - s;
}
-int coe(int fd)
-{
- return fcntl(fd, F_SETFD, FD_CLOEXEC);
-}
-
#ifdef UNUSED
static /* as it isn't used anywhere else */
void tai_pack(char *s, const struct tai *t)
diff --git a/runit/runit_lib.h b/runit/runit_lib.h
index c644f5b9d..4b9482024 100644
--- a/runit/runit_lib.h
+++ b/runit/runit_lib.h
@@ -27,8 +27,6 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
extern unsigned byte_chr(char *s,unsigned n,int c);
-extern int coe(int);
-
#define direntry struct dirent
//struct tai {
diff --git a/runit/runsv.c b/runit/runsv.c
index 1ee3dda01..7cf142d8a 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -454,8 +454,8 @@ int runsv_main(int argc, char **argv)
dir = argv[1];
xpipe(selfpipe);
- coe(selfpipe[0]);
- coe(selfpipe[1]);
+ close_on_exec_on(selfpipe[0]);
+ close_on_exec_on(selfpipe[1]);
ndelay_on(selfpipe[0]);
ndelay_on(selfpipe[1]);
@@ -491,8 +491,8 @@ int runsv_main(int argc, char **argv)
if (stat("log/down", &s) != -1)
svd[1].want = W_DOWN;
xpipe(logpipe);
- coe(logpipe[0]);
- coe(logpipe[1]);
+ close_on_exec_on(logpipe[0]);
+ close_on_exec_on(logpipe[1]);
}
}
@@ -512,7 +512,7 @@ int runsv_main(int argc, char **argv)
O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600);
if (lock_exnb(svd[0].fdlock) == -1)
fatal_cannot("lock supervise/lock");
- coe(svd[0].fdlock);
+ close_on_exec_on(svd[0].fdlock);
if (haslog) {
if (mkdir("log/supervise", 0700) == -1) {
r = readlink("log/supervise", buf, 256);
@@ -536,30 +536,30 @@ int runsv_main(int argc, char **argv)
O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600);
if (lock_ex(svd[1].fdlock) == -1)
fatal_cannot("lock log/supervise/lock");
- coe(svd[1].fdlock);
+ close_on_exec_on(svd[1].fdlock);
}
mkfifo("log/supervise/control"+4, 0600);
svd[0].fdcontrol = xopen("log/supervise/control"+4, O_RDONLY|O_NDELAY);
- coe(svd[0].fdcontrol);
+ close_on_exec_on(svd[0].fdcontrol);
svd[0].fdcontrolwrite = xopen("log/supervise/control"+4, O_WRONLY|O_NDELAY);
- coe(svd[0].fdcontrolwrite);
+ close_on_exec_on(svd[0].fdcontrolwrite);
update_status(&svd[0]);
if (haslog) {
mkfifo("log/supervise/control", 0600);
svd[1].fdcontrol = xopen("log/supervise/control", O_RDONLY|O_NDELAY);
- coe(svd[1].fdcontrol);
+ close_on_exec_on(svd[1].fdcontrol);
svd[1].fdcontrolwrite = xopen("log/supervise/control", O_WRONLY|O_NDELAY);
- coe(svd[1].fdcontrolwrite);
+ close_on_exec_on(svd[1].fdcontrolwrite);
update_status(&svd[1]);
}
mkfifo("log/supervise/ok"+4, 0600);
fd = xopen("log/supervise/ok"+4, O_RDONLY|O_NDELAY);
- coe(fd);
+ close_on_exec_on(fd);
if (haslog) {
mkfifo("log/supervise/ok", 0600);
fd = xopen("log/supervise/ok", O_RDONLY|O_NDELAY);
- coe(fd);
+ close_on_exec_on(fd);
}
for (;;) {
struct pollfd x[3];
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index 8d25923d4..924f771b7 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -190,8 +190,8 @@ static int setup_log(void)
warnx("cannot create pipe for log");
return -1;
}
- coe(logpipe[1]);
- coe(logpipe[0]);
+ close_on_exec_on(logpipe[1]);
+ close_on_exec_on(logpipe[0]);
ndelay_on(logpipe[0]);
ndelay_on(logpipe[1]);
if (dup2(logpipe[1], 2) == -1) {
@@ -245,7 +245,7 @@ int runsvdir_main(int argc, char **argv)
curdir = open_read(".");
if (curdir == -1)
fatal2_cannot("open current directory", "");
- coe(curdir);
+ close_on_exec_on(curdir);
stampcheck = monotonic_sec();
diff --git a/runit/svlogd.c b/runit/svlogd.c
index b5eed15ab..cdf4e424b 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -361,7 +361,7 @@ static unsigned rotate(struct logdir *ld)
/* we presume this cannot fail */
ld->filecur = fdopen(ld->fdcur, "a"); ////
setvbuf(ld->filecur, NULL, _IOFBF, linelen); ////
- coe(ld->fdcur);
+ close_on_exec_on(ld->fdcur);
ld->size = 0;
while (fchmod(ld->fdcur, 0644) == -1)
pause2cannot("set mode of current", ld->name);
@@ -482,7 +482,7 @@ static unsigned logdir_open(struct logdir *ld, const char *fn)
warn2("cannot open log directory", (char*)fn);
return 0;
}
- coe(ld->fddir);
+ close_on_exec_on(ld->fddir);
if (fchdir(ld->fddir) == -1) {
logdir_close(ld);
warn2("cannot change directory", (char*)fn);
@@ -498,7 +498,7 @@ static unsigned logdir_open(struct logdir *ld, const char *fn)
pause1cannot("change to initial working directory");
return 0;
}
- coe(ld->fdlock);
+ close_on_exec_on(ld->fdlock);
ld->size = 0;
ld->sizemax = 1000000;
@@ -624,7 +624,7 @@ static unsigned logdir_open(struct logdir *ld, const char *fn)
ld->filecur = fdopen(ld->fdcur, "a"); ////
setvbuf(ld->filecur, NULL, _IOFBF, linelen); ////
- coe(ld->fdcur);
+ close_on_exec_on(ld->fdcur);
while (fchmod(ld->fdcur, 0644) == -1)
pause2cannot("set mode of current", ld->name);
@@ -851,7 +851,7 @@ int svlogd_main(int argc, char **argv)
if (dirn <= 0) usage();
////if (buflen <= linemax) usage();
fdwdir = xopen(".", O_RDONLY|O_NDELAY);
- coe(fdwdir);
+ close_on_exec_on(fdwdir);
dir = xzalloc(dirn * sizeof(struct logdir));
for (i = 0; i < dirn; ++i) {
dir[i].fddir = -1;