title: Linux reboot() system call: why it calls do_exit(0) after kernel_halt()?
body: <p>This is related to: <a href="https://stackoverflow.com/a/13413099/1284631">https://stackoverflow.com/a/13413099/1284631</a></p>
  
  <p>Now, the question is:</p>
  
  <p>Why the reboot() system call, when called with <code>LINUX_REBOOT_CMD_HALT</code> parameter (see here: <a href="http://lxr.linux.no/linux+v3.6.6/kernel/sys.c#L480" rel="nofollow noreferrer">http://lxr.linux.no/linux+v3.6.6/kernel/sys.c#L480</a>) is calling <code>do_exit(0)</code> after having already called <code>kernel_halt()</code>, as calling <code>kernel_halt()</code> boils down to calling <code>stop_this_cpu()</code> (see here: <a href="http://lxr.linux.no/linux+v3.6.6/arch/x86/kernel/process.c#L519" rel="nofollow noreferrer">http://lxr.linux.no/linux+v3.6.6/arch/x86/kernel/process.c#L519</a>), as part of <code>native_machine_halt()</code> (see here: <a href="http://lxr.linux.no/linux+v3.6.6/arch/x86/kernel/reboot.c#L680" rel="nofollow noreferrer">http://lxr.linux.no/linux+v3.6.6/arch/x86/kernel/reboot.c#L680</a>).</p>
  
  <p>Or, it seems to me that <code>stop_this_cpu()</code> is never returning (it ends with an infinite loop).</p>
  
  <p>So, it is <code>do_exit(0)</code> called just in case that <code>kernel_halt()</code> doesn't do its job and it return? Why not <code>panic()</code> directly instead, then?</p>