summaryrefslogtreecommitdiff
path: root/src/sysexec.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysexec.hpp')
-rw-r--r--src/sysexec.hpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/sysexec.hpp b/src/sysexec.hpp
index 73a18bf..85efaa0 100644
--- a/src/sysexec.hpp
+++ b/src/sysexec.hpp
@@ -10,9 +10,16 @@ int execScript(std::string const& script, std::string const& ifname)
int fd;
for (fd=getdtablesize();fd>=0;--fd) // close all file descriptors
close(fd);
- fd=open("/dev/null",O_RDWR); // stdin
- dup(fd); // stdout
- dup(fd); // stderr
+
+ fd = open("/dev/null",O_RDWR); // stdin
+ if(fd == -1)
+ cLog.msg(Log::PRIO_WARNING) << "can't open stdin";
+ else {
+ if(dup(fd) == -1) // stdout
+ cLog.msg(Log::PRIO_WARNING) << "can't open stdout";
+ if(dup(fd) == -1) // stderr
+ cLog.msg(Log::PRIO_WARNING) << "can't open stderr";
+ }
return execl("/bin/sh", "/bin/sh", script.c_str(), ifname.c_str(), NULL);
}
int status = 0;