Say I am writing my own init program running on a Linux kernel.
What happens when my init program exits with return value 0 ?
Additionally is the behaviour different if the return value is non-zero?
Say I am writing my own init program running on a Linux kernel.
What happens when my init program exits with return value 0 ?
Additionally is the behaviour different if the return value is non-zero?
What happens when my init program exits with return value 0?
This code, from the find_child_reaper
function in kernel/exit.c
, is run:
panic("Attempted to kill init! exitcode=0x%08x\n", father->signal->group_exit_code ?: father->exit_code);
And consequently this message appears on your console:
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
main
in aC
program, you return to a stub function in theC
library that then invokes a system call to end the process, just as if you calledexit()
. – DepressedDaniel Mar 21 '17 at 22:54?:
means, look here: https://stackoverflow.com/a/3319144. In summary: the syntaxx ?: y
is a nonstandard GCC extension and is equivalent tox ? x : y
. – jp48 Aug 06 '19 at 20:13