summaryrefslogtreecommitdiff
path: root/src/sysexec.hpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-20 14:12:13 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-20 14:12:13 +0000
commita01eb22a8711b174c4d8e28a0dba17d395cb39fe (patch)
tree2f240aae5ea141d444804dec001a8a41178fa896 /src/sysexec.hpp
parentadded actual_node_ to linux and bsd device as well (diff)
improved esit status handling of exec script for unix
added dev actual node as parameter to exec script
Diffstat (limited to 'src/sysexec.hpp')
-rw-r--r--src/sysexec.hpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/sysexec.hpp b/src/sysexec.hpp
index f2d5d35..2883102 100644
--- a/src/sysexec.hpp
+++ b/src/sysexec.hpp
@@ -33,7 +33,7 @@
#define _SYSEXEC_HPP
#ifndef NO_EXEC
-int execScript(std::string const& script, std::string const& ifname)
+int execScript(std::string const& script, std::string const& ifname, std::string const& ifnode)
{
pid_t pid;
pid = fork();
@@ -51,10 +51,18 @@ int execScript(std::string const& script, std::string const& ifname)
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);
+ execl("/bin/sh", "/bin/sh", script.c_str(), ifname.c_str(), ifnode.c_str(), (char*)NULL);
+ // if execl return, an error occurred
+ cLog.msg(Log::PRIO_ERR) << "error on executing script: " << LogErrno(errno);
+ return -1;
}
int status = 0;
waitpid(pid, &status, 0);
+ if(WIFEXITED(status))
+ cLog.msg(Log::PRIO_NOTICE) << "script '" << script << "' returned " << WEXITSTATUS(status);
+ if(WIFSIGNALED(status))
+ cLog.msg(Log::PRIO_NOTICE) << "script '" << script << "' terminated after signal " << WTERMSIG(status);
+
return status;
}