Verified Commit c767d551 authored by Felix Kopp's avatar Felix Kopp
Browse files

initd: implement simple test init daemon

parent 104578d0
......@@ -71,7 +71,7 @@ configure_file(
add_subdirectory(arch)
#add_subdirectory(init)
add_subdirectory(init)
add_subdirectory(kernel)
add_subdirectory(lib)
......@@ -86,7 +86,7 @@ add_custom_command(
COMMAND ${CMAKE_LINKER}
ARGS ${ARDIX_LINKER_FLAGS} -o ardix.elf
$<TARGET_FILE:ardix_arch>
#$<TARGET_FILE:ardix_init>
$<TARGET_FILE:ardix_init>
$<TARGET_FILE:ardix_kernel>
$<TARGET_FILE:ardix_kernel_fs>
$<TARGET_FILE:ardix_lib>
......
/* See the end of this file for copyright, license, and warranty information. */
#include <ardix/io.h>
#include <ardix/kent.h>
#include <ardix/kevent.h>
#include <ardix/sched.h>
#include <config.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
int child_test(void)
{
printf("[child ] i'm so sleempy,, calling sleep(),,\n");
sleep(1000);
printf("[child ] sleep() returned, i'm gonna kill myself now uwu\n");
return 69;
}
/**
* @brief init daemon entry point.
*/
int init_main(void)
{
printf("[parent] calling exec()\n");
pid_t pid = exec(child_test);
printf("[parent] exec() returned, child pid = %d\n", pid);
int status;
printf("[parent] calling waitpid()\n");
waitpid(-1, &status, 0);
printf("[parent] waitpid() returned, child exit code = %d\n", status);
printf("[parent] my child has died, goodbye cruel world qwq\n");
return 0;
}
/*
* This file is part of Ardix.
* Copyright (c) 2020, 2021 Felix Kopp <owo@fef.moe>.
*
* Ardix is non-violent software: you may only use, redistribute,
* and/or modify it under the terms of the CNPLv6+ as found in
* the LICENSE file in the source code root directory or at
* <https://git.pixie.town/thufie/CNPL>.
*
* Ardix comes with ABSOLUTELY NO WARRANTY, to the extent
* permitted by applicable law. See the CNPLv6+ for details.
*/
......@@ -12,6 +12,8 @@
#include <stdio.h>
#include <unistd.h>
extern int init_main(void); /* init/main.c */
/**
* Core init routine.
*
......@@ -44,9 +46,10 @@ int main(void)
printf("This is non-violent software, and there is NO WARRANTY.\n");
printf("See <https://git.fef.moe/fef/ardix> for details.\n\n");
/* TODO: The next big step is to write initd and fork to it here. */
while (1)
sleep(1000);
pid_t pid = exec(init_main);
waitpid(pid, &err, 0);
printf("initd exited with status %d, system halted\n", err);
while (1);
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment