| 113 | } |
| 114 | |
| 115 | int forkcall(const std::function<int()> &lambda) |
| 116 | { |
| 117 | pid_t pid = fork(); |
| 118 | if (pid == -1) |
| 119 | return -1; |
| 120 | if (pid == 0) { |
| 121 | exit(lambda()); |
| 122 | } else { |
| 123 | int status = -1; |
| 124 | waitpid(pid, &status, 0); |
| 125 | if (WIFEXITED(status)) { |
| 126 | return WEXITSTATUS(status); |
| 127 | } |
| 128 | } |
| 129 | return -1; |
| 130 | } |
| 131 | |
| 132 | static inline int seccomp(int op, int fd, void *arg) { |
| 133 | return syscall(SYS_seccomp, op, fd, arg); |