Initial setup

This commit is contained in:
2026-10-08 12:46:54 +01:00
commit 2fd5989756
6 changed files with 345 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <cstdlib>
#include <iostream>
int main()
{
// PID 1
int console = open("/dev/console", O_RDWR);
if (console < 0)
{
perror("open /dev/console");
return 1;
}
dup2(console, STDIN_FILENO);
dup2(console, STDOUT_FILENO);
dup2(console, STDERR_FILENO);
close(console);
while (true)
{
pid_t pid = fork();
if (pid == 0)
{
execl("/bin/sh", "sh", nullptr);
perror("exec");
_exit(127);
}
if (pid > 0)
{
waitpid(pid, nullptr, 0);
}
}
}
View File