EnderIce2 23a17fae00
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
userspace/init: dummy code
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-01-28 12:26:53 +02:00

70 lines
1.4 KiB
C

/*
This file is part of Fennix Userspace.
Fennix Userspace is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Userspace is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Userspace. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
void StartProcess(const char *program, char *const argv[])
{
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;
}