8

I always have /proc/sys/kernel/panic set up to 0. Looking at description of this option in kernel.org we can see:

panic:

The value in this file represents the number of seconds the kernel waits before rebooting on a panic. When you use the software watchdog, the recommended setting is 60.

From here one can conclude that 0 is 0 seconds waiting before reboot - immediate reboot.
But proc MAN page states the following:

/proc/sys/kernel/panic
This file gives read/write access to the kernel variable panic_timeout. If this is zero, the kernel will loop on a panic; if nonzero, it indicates that the kernel should autore‐ boot after this number of seconds. When you use the software watchdog device driver, the recommended setting is 60.

Here 0 means antipodal thing - never reboot.

So why such a trusted source gives such a misleading info? Or maybe the MAN page is inaccurate?

P.S. just from a hint in panic_on_oops section (if you happen to read this) you can guess that MAN page is right. Or if you are technically skilled enough to investigate something in kernel source code.

1
  • "one can conclude" it's possible for conclusions to be incorrectly drawn.
    – RonJohn
    Commented Jan 30, 2020 at 3:08

2 Answers 2

22

The authoritative source is the implementation in the kernel, so let’s look at that first.

The panic entry in sysctl corresponds to a kernel variable called panic_timeout. This is a signed integer, used to control behaviour on panic as follows:

  • if panic_timeout is strictly positive, the kernel waits after a panic, for panic_timeout seconds;
  • if panic_timeout is non-zero, the kernel reboots after a panic (after waiting, if appropriate);
  • if the kernel hasn’t rebooted, it prints a message and loops forever.

So the manpage is correct, and the kernel’s own documentation was incomplete; but sysctl/kernel.rst now documents panic in more detail. This was fixed in version 5.7-rc1 of the kernel.

0
2

So why such a trusted source gives such a misleading info?

First it is only slightly misleading - you rather jump to your conclusion - than a misktake. I would say the kernel.org neglects the special case "0".

I don't know the details of kernel.org, but in essence it is a mix of official kernel Documentation/ (web formatted, grouped), plus some additional info. Best example is the boot params list, which is "gathered" from different places, as they put it.

"kernel.org" lists the "Documentation" link under "Other Resources". It takes you to doc/html/latest/. There is also a mixed bag of links under /doc.

Right at the start the (sphinx formatted) Documentation says:

Kernel documentation, like the kernel itself, is very much a work in progress; that is especially true as we work to integrate our many scattered documents into a coherent whole. Please note that improvements to the documentation are welcome;...

The man 5 proc is part of man-pages project (or package), and there is this guy with the book-to-stun-an-ox who is maintaining it. These pages all have "COLOPHON" as subtitle (section) at the end. They are also heterogenous, some just collected (all the POSIX "1p" pages), and some written to fill the gaps.

On man7.org you directly see Mr. Kerrisk's oeuvre -- I think he does a good job, selling his book but maintaining a collection of open source man pages.

I this case, he is more precise. Both seem related, of course ("When you...device driver... 60").


we work to integrate our many scattered documents into a coherent whole.

This only makes halfways sense. Whose documents were scattered, and by whom?


My pseudocode goes like this:

if timeout > 0   then loop for 'timeout' seconds
if timeout != 0  then reboot
loop for ever

Which means a negative value is immediate reboot, and a positive one has both ifs true. And zero leads directly to the final loop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .