Commit 6df067c5 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

util: Make sure open successed

Opening /dev/null may fail, check for ret code.

CID 1168167
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 708abf40
...@@ -597,6 +597,10 @@ int cr_daemon(int nochdir, int noclose) ...@@ -597,6 +597,10 @@ int cr_daemon(int nochdir, int noclose)
int fd; int fd;
fd = open("/dev/null", O_RDWR); fd = open("/dev/null", O_RDWR);
if (fd < 0) {
pr_perror("Can't open /dev/null");
return -1;
}
dup2(fd, 0); dup2(fd, 0);
dup2(fd, 1); dup2(fd, 1);
dup2(fd, 2); dup2(fd, 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment