From a01eb22a8711b174c4d8e28a0dba17d395cb39fe Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 20 Jan 2009 14:12:13 +0000 Subject: improved esit status handling of exec script for unix added dev actual node as parameter to exec script --- src/sysexec.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/sysexec.hpp') 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; } -- cgit v1.2.3