summaryrefslogtreecommitdiffhomepage
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-16 13:20:56 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-16 13:20:56 +0000
commit3718832a1542f7bf786a1678741b8566ad3a35c6 (patch)
treeac5851de53237fb3a0c77c9cead27acd279897f0 /miscutils
parent1e18f1bab3400246129756a35bb5752ba98f4c90 (diff)
*: more readable handling of pipe fds. No code changes.
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/crontab.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index 71037b7ee..b292535b1 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -70,18 +70,18 @@ static void edit_file(const struct passwd *pas, const char *file)
static int open_as_user(const struct passwd *pas, const char *file)
{
- int filedes[2];
+ struct fd_pair filedes;
pid_t pid;
char c;
- xpipe(filedes);
+ xpiped_pair(filedes);
pid = vfork();
if (pid < 0) /* ERROR */
bb_perror_msg_and_die("vfork");
if (pid) { /* PARENT */
- int n = safe_read(filedes[0], &c, 1);
- close(filedes[0]);
- close(filedes[1]);
+ int n = safe_read(filedes.rd, &c, 1);
+ close(filedes.rd);
+ close(filedes.wr);
if (n > 0) /* child says it can read */
return open(file, O_RDONLY);
return -1;
@@ -95,7 +95,7 @@ static int open_as_user(const struct passwd *pas, const char *file)
/* We just try to read one byte. If that works, file is readable
* under this user. We signal that by sending one byte to parent. */
if (safe_read(xopen(file, O_RDONLY), &c, 1) == 1)
- safe_write(filedes[1], &c, 1); /* "papa, I can read!" */
+ safe_write(filedes.wr, &c, 1); /* "papa, I can read!" */
_exit(0);
}