aboutsummaryrefslogtreecommitdiff
path: root/runit
diff options
context:
space:
mode:
Diffstat (limited to 'runit')
-rw-r--r--runit/runit_lib.c28
-rw-r--r--runit/runit_lib.h6
-rw-r--r--runit/runsv.c6
-rw-r--r--runit/runsvdir.c2
-rw-r--r--runit/svlogd.c14
5 files changed, 9 insertions, 47 deletions
diff --git a/runit/runit_lib.c b/runit/runit_lib.c
index 0830314df..4762096b4 100644
--- a/runit/runit_lib.c
+++ b/runit/runit_lib.c
@@ -61,34 +61,6 @@ int coe(int fd)
}
-/*** fd_copy.c ***/
-
-int fd_copy(int to,int from)
-{
- if (to == from)
- return 0;
- if (fcntl(from,F_GETFL,0) == -1)
- return -1;
- close(to);
- if (fcntl(from,F_DUPFD,to) == -1)
- return -1;
- return 0;
-}
-
-
-/*** fd_move.c ***/
-
-int fd_move(int to,int from)
-{
- if (to == from)
- return 0;
- if (fd_copy(to,from) == -1)
- return -1;
- close(from);
- return 0;
-}
-
-
/*** fmt_ptime.c ***/
void fmt_ptime30nul(char *s, struct taia *ta) {
diff --git a/runit/runit_lib.h b/runit/runit_lib.h
index 7b268e276..9fe4166bc 100644
--- a/runit/runit_lib.h
+++ b/runit/runit_lib.h
@@ -40,12 +40,6 @@ extern int coe(int);
#define direntry struct dirent
-/*** fd.h ***/
-
-extern int fd_copy(int,int);
-extern int fd_move(int,int);
-
-
/*** tai.h ***/
struct tai {
diff --git a/runit/runsv.c b/runit/runsv.c
index cd806851e..018456847 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -251,7 +251,7 @@ static unsigned custom(struct svdir *s, char c)
return 0;
}
if (!pid) {
- if (haslog && fd_copy(1, logpipe[1]) == -1)
+ if (haslog && dup2(logpipe[1], 1) == -1)
warn_cannot("setup stdout for control/?");
prog[0] = a;
prog[1] = NULL;
@@ -312,13 +312,13 @@ static void startservice(struct svdir *s)
/* child */
if (haslog) {
if (s->islog) {
- if (fd_copy(0, logpipe[0]) == -1)
+ if (dup2(logpipe[0], 0) == -1)
fatal_cannot("setup filedescriptor for ./log/run");
close(logpipe[1]);
if (chdir("./log") == -1)
fatal_cannot("change directory to ./log");
} else {
- if (fd_copy(1, logpipe[1]) == -1)
+ if (dup2(logpipe[1], 1) == -1)
fatal_cannot("setup filedescriptor for ./run");
close(logpipe[0]);
}
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index 2f54cfef8..cce2c5d9c 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -191,7 +191,7 @@ static int setup_log(void)
coe(logpipe[0]);
ndelay_on(logpipe[0]);
ndelay_on(logpipe[1]);
- if (fd_copy(2, logpipe[1]) == -1) {
+ if (dup2(logpipe[1], 2) == -1) {
warnx("cannot set filedescriptor for log");
return -1;
}
diff --git a/runit/svlogd.c b/runit/svlogd.c
index e454bace8..fb834a403 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -153,12 +153,10 @@ static unsigned processorstart(struct logdir *ld)
if (verbose)
bb_error_msg(INFO"processing: %s/%s", ld->name, ld->fnsave);
fd = xopen(ld->fnsave, O_RDONLY|O_NDELAY);
- if (fd_move(0, fd) == -1)
- bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+ xmove_fd(fd, 0);
ld->fnsave[26] = 't';
fd = xopen(ld->fnsave, O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
- if (fd_move(1, fd) == -1)
- bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+ xmove_fd(fd, 1);
fd = open_read("state");
if (fd == -1) {
if (errno != ENOENT)
@@ -166,17 +164,15 @@ static unsigned processorstart(struct logdir *ld)
close(xopen("state", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT));
fd = xopen("state", O_RDONLY|O_NDELAY);
}
- if (fd_move(4, fd) == -1)
- bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+ xmove_fd(fd, 4);
fd = xopen("newstate", O_WRONLY|O_NDELAY|O_TRUNC|O_CREAT);
- if (fd_move(5, fd) == -1)
- bb_perror_msg_and_die(FATAL"cannot %s processor %s", "move filedescriptor for", ld->name);
+ xmove_fd(fd, 5);
// getenv("SHELL")?
prog[0] = (char*)"sh";
prog[1] = (char*)"-c";
prog[2] = ld->processor;
- prog[3] = '\0';
+ prog[3] = NULL;
execve("/bin/sh", prog, environ);
bb_perror_msg_and_die(FATAL"cannot %s processor %s", "run", ld->name);
}