Quantcast
Viewing all articles
Browse latest Browse all 5300

Raspberry Pi OS • Re: Lost console history when shutting down with on/off button

Note to OP: I understood what you meant by "console history" - even though the term was used imprecisely. I just think some of the other posters here interpreted it differently (i.e., more literally).

Anyway, based on some quick research (and not having a Pi 5 myself to test with), it looks like pressing the button doesn't actually run the shutdown command. Instead, it shuts down using a quicker method, based on setting some GPIO. I assume that this method of shutting down does the bare minimum of stuff needed to shut down safely (flushes disk buffers) and doesn't do all the bells and whistles that running shutdown does.

In particular, a "normal" shutdown will send a signal (usually SIGHUP) to all processes then wait for a few seconds before sending a fatal signal (SIGKILL). The idea is that in that time period, the process could catch the signal and shut itself down cleanly. Shells (e.g., bash) are supposed to catch SIGHUP and write out their history file before exiting. So, normally, like when you do it from a SSH login, it should "do the right thing".

But in the case of the quick shutdown described above, the shell doesn't get a chance to catch the signal (since no signal is sent).

If my assumptions are correct, then I don't see any way to fix this.

Statistics: Posted by BigRedMailbox — Thu May 16, 2024 7:50 pm



Viewing all articles
Browse latest Browse all 5300

Trending Articles