forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
34 lines (29 loc) 路 802 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <AK/Assertions.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char** argv)
{
if (pledge("stdio tty proc exec", nullptr) < 0) {
perror("pledge");
return 1;
}
if (argc < 2)
return -1;
dbgprintf("Starting console server on %s\n", argv[1]);
while (true) {
dbgprintf("Running shell on %s\n", argv[1]);
auto child = fork();
if (!child) {
int rc = execl("/bin/Shell", "Shell", nullptr);
ASSERT(rc < 0);
perror("execl");
exit(127);
} else {
int wstatus;
waitpid(child, &wstatus, 0);
dbgprintf("Shell on %s exited with code %d\n", argv[1], WEXITSTATUS(wstatus));
}
}
}