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?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityWhat 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 a C
program, you return to a stub function in the C
library that then invokes a system call to end the process, just as if you called exit()
.
Mar 21, 2017 at 22:54
?:
means, look here: stackoverflow.com/a/3319144. In summary: the syntax x ?: y
is a nonstandard GCC extension and is equivalent to x ? x : y
.