userspace/init: dummy code
Some checks failed
Build OS / Build Cross-Compiler & Toolchain (push) Successful in 1h46m32s
Build OS / Deploy Documentation to GitHub Pages (push) Failing after 4m27s
Build OS / Analyze (${{ matrix.language }}) (manual, c-cpp) (push) Failing after 6m13s
Build OS / Build amd64 (push) Failing after 14m44s
Build OS / Build i386 (push) Failing after 16m28s
Build OS / Build aarch64 (push) Failing after 11m17s
Build OS / Build arm (push) Failing after 15m17s

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-01-28 12:26:53 +02:00
parent d7bccb6948
commit 23a17fae00
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A

View File

@ -19,9 +19,51 @@
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int, char *[], char *[])
void StartProcess(const char *program, char *const argv[])
{
printf("Hello, World!\n");
pid_t pid = fork();
if (pid == 0)
{
execvp(program, argv);
perror("execvp");
exit(EXIT_FAILURE);
}
else if (pid < 0)
{
perror("fork");
exit(EXIT_FAILURE);
}
}
void ReapZombies()
{
while (1)
{
int status;
pid_t pid = waitpid(-1, &status, WNOHANG);
if (pid <= 0)
break;
}
}
int main()
{
printf("init starting...\n");
char *shellArgs[] = {"/bin/sh", NULL};
StartProcess("/bin/sh", shellArgs);
// char *dummyServiceArgs[] = {"/usr/bin/dummy_service", NULL};
// StartProcess("/usr/bin/dummy_service", dummyServiceArgs);
while (1)
{
ReapZombies();
sleep(1);
}
return 0;
}