mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
don't fail too bad, if /dev/null does not exist
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
This commit is contained in:
parent
7d38d2287c
commit
af5461f72f
@ -136,23 +136,19 @@ int run_program(const char *command, const char *subsystem,
|
||||
|
||||
/* discard child output or connect to pipe */
|
||||
devnull = open("/dev/null", O_RDWR);
|
||||
if (devnull < 0) {
|
||||
err("open /dev/null failed");
|
||||
exit(1);
|
||||
}
|
||||
if (devnull > 0) {
|
||||
dup2(devnull, STDIN_FILENO);
|
||||
|
||||
if (outpipe[1] < 0)
|
||||
dup2(devnull, STDOUT_FILENO);
|
||||
if (errpipe[1] < 0)
|
||||
dup2(devnull, STDERR_FILENO);
|
||||
close(devnull);
|
||||
} else
|
||||
err("open /dev/null failed");
|
||||
if (outpipe[1] > 0)
|
||||
dup2(outpipe[1], STDOUT_FILENO);
|
||||
else
|
||||
dup2(devnull, STDOUT_FILENO);
|
||||
|
||||
if (errpipe[1] > 0)
|
||||
dup2(errpipe[1], STDERR_FILENO);
|
||||
else
|
||||
dup2(devnull, STDERR_FILENO);
|
||||
|
||||
close(devnull);
|
||||
execv(arg, argv);
|
||||
|
||||
/* we should never reach this */
|
||||
|
14
udevd.c
14
udevd.c
@ -785,7 +785,7 @@ int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
int maxsockplus;
|
||||
int retval;
|
||||
int fd;
|
||||
int devnull;
|
||||
struct sigaction act;
|
||||
fd_set readfds;
|
||||
const char *value;
|
||||
@ -841,12 +841,12 @@ int main(int argc, char *argv[], char *envp[])
|
||||
setpriority(PRIO_PROCESS, 0, UDEVD_PRIORITY);
|
||||
|
||||
/* Set fds to dev/null */
|
||||
fd = open( "/dev/null", O_RDWR );
|
||||
if (fd >= 0) {
|
||||
dup2(fd, STDIN_FILENO);
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
dup2(fd, STDERR_FILENO);
|
||||
close(fd);
|
||||
devnull = open( "/dev/null", O_RDWR );
|
||||
if (devnull > 0) {
|
||||
dup2(devnull, STDIN_FILENO);
|
||||
dup2(devnull, STDOUT_FILENO);
|
||||
dup2(devnull, STDERR_FILENO);
|
||||
close(devnull);
|
||||
} else
|
||||
err("error opening /dev/null %s", strerror(errno));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user