Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/zenroom.c b/src/zenroom.c
- index 2442872..5330ff4 100644
- --- a/src/zenroom.c
- +++ b/src/zenroom.c
- @@ -23,6 +23,10 @@
- #include <string.h>
- #include <ctype.h>
- +#include <wait.h>
- +#include <sys/prctl.h>
- +#include <linux/seccomp.h>
- +
- #include <errno.h>
- #include <lua.h>
- @@ -305,6 +309,7 @@ int main(int argc, char **argv) {
- const char *short_options = "hdic:k:a:p:";
- const char *help =
- "Usage: zenroom [-dh] [ -i ] [ -c config ] [ -k keys ] [ -a data ] [ [ -p ] script.lua ]\n";
- + int pid, status, retval;
- conffile [0] = '\0';
- scriptfile [0] = '\0';
- keysfile [0] = '\0';
- @@ -419,8 +424,28 @@ int main(int argc, char **argv) {
- if(!Z) {
- error(NULL, "Initialisation failed.");
- return 1; }
- - if( zen_exec_script(Z, script) ) error(NULL, "Blocked execution.");
- - else notice(NULL, "Execution completed.");
- + if (fork() == 0) {
- + prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT);
- + notice(NULL, "Starting execution.");
- + if( zen_exec_script(Z, script) ) {
- + error(NULL, "Blocked execution.");
- + exit(1);
- + }
- + exit(0);
- + }
- +
- + do {
- + pid = wait(&status);
- + } while(pid == -1);
- +
- + if (WIFEXITED(status)) {
- + retval = WEXITSTATUS(status);
- + if (retval == 0)
- + notice(NULL, "Execution completed.");
- + } else if (WIFSIGNALED(status)) {
- + notice(NULL, "Execution interrupted by signal %d.", WTERMSIG(status));
- + }
- +
- // report experimental memory manager
- // if((strcmp(conffile,"umm")==0) && zen_heap) {
- // lua_gc(L, LUA_GCCOLLECT, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement