mirror of
https://github.com/troglobit/finit.git
synced 2026-11-08 16:11:10 +00:00
service: minor refactor of stdin redirect
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 file changed
+10
-9
+10
-9
@@ -208,13 +208,16 @@ static int stdin_redirect(void)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = open("/dev/null", O_RDONLY | O_APPEND);
|
fd = open("/dev/null", O_RDONLY);
|
||||||
if (-1 != fd) {
|
if (fd == -1) {
|
||||||
dup2(fd, STDIN_FILENO);
|
warn("Failed opening /dev/null for stdin redirect");
|
||||||
return close(fd);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
dup2(fd, STDIN_FILENO);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -261,12 +264,10 @@ static void fallback_logger(char *ident, char *prio)
|
|||||||
static int lredirect(svc_t *svc)
|
static int lredirect(svc_t *svc)
|
||||||
{
|
{
|
||||||
static int have_sysklogd = -1;
|
static int have_sysklogd = -1;
|
||||||
pid_t pid, svc_pid;
|
pid_t svc_pid = getpid();
|
||||||
|
pid_t pid;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
svc_pid = getpid();
|
|
||||||
dbg("%s pid: %d", svc_ident(svc, NULL, 0), svc_pid);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open PTY to connect to logger. A pty isn't buffered
|
* Open PTY to connect to logger. A pty isn't buffered
|
||||||
* like a pipe, and it eats newlines so they aren't logged
|
* like a pipe, and it eats newlines so they aren't logged
|
||||||
|
|||||||
Reference in new issue
Block a user