summaryrefslogtreecommitdiff
path: root/src/sysexec.h
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-20 17:08:44 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-20 17:08:44 +0000
commit7c6d915acf67815f1699644f71cd851b685f0ce6 (patch)
treeb2babeeabe406b9119c3665a2f27edc4582c84f0 /src/sysexec.h
parentswitching key derivation prf to null if no auth or no enc (diff)
updated exit status handling of exec script
Diffstat (limited to 'src/sysexec.h')
-rw-r--r--src/sysexec.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/sysexec.h b/src/sysexec.h
index 2b01bc8..04226a1 100644
--- a/src/sysexec.h
+++ b/src/sysexec.h
@@ -56,11 +56,22 @@ int exec_script(const char* script, const char* ifname)
if(dup(fd) == -1) // stderr
log_printf(WARNING, "can't open stderr");
}
- return execl("/bin/sh", "/bin/sh", script, ifname, NULL);
+ execl("/bin/sh", "/bin/sh", script, ifname, NULL);
+ // if execl return, an error occurred
+ log_printf(ERR, "error on executing script: %m");
+ return -1;
}
int status = 0;
waitpid(pid, &status, 0);
+ if(WIFEXITED(status))
+ log_printf(NOTICE, "script '%s' returned %d", script, WEXITSTATUS(status));
+ else if(WIFSIGNALED(status))
+ log_printf(NOTICE, "script '%s' terminated after signal %d", script, WTERMSIG(status));
+ else
+ log_printf(ERR, "executing script: unkown error");
+
return status;
+
}
#endif