<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 7/29/2014 11:09 PM, Jim Kinney
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAEo=5Py3pkFf2m60yPrAMZrUMsyhFg=eqFUTBDJrKMMQe46mDg@mail.gmail.com"
      type="cite">
      <pre wrap="">So you're working away and suddenly you get a console error message:
Kernel: BUG: &lt;fill in your fav thing to break here&gt;
and that console pukes and locks.
You're loged in remote over and ssh session and screen. You can't reattach
to that screen session and then, WHAM, another one pops in and informs you
also that cpu core #19 has timed out for the past 67 seconds.</pre>
    </blockquote>
    Something I have had to do many times in the past, as many
    environments have no sysrq hooks enabled...<br>
    <pre>#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;linux/reboot.h&gt;

int
main() {
  /*
   * Should not return; forces an un-sync'd kernel reboot.
   */
  int status = reboot(LINUX_REBOOT_CMD_RESTART);

  // If we're still here...
  fprintf(stderr, "Failed to reboot system---are you root?");
  return 1;
}
</pre>
    Have this handy!  32-bit and 64-bit statically-linked versions
    (against uclibc or newlib---NOT glibc) which you can easily transfer
    over an SSH session in hexdump form.<br>
    <br>
    When needed, place this file in /dev and call it as /dev/reboot32 or
    /dev/reboot64.  You can use sftp/scp if the system stays up long
    enough.  If not, do the following song and dance:<br>
    <ul>
      <li>On local system: xxd /path/to/reboot-file (or have
        /path/to/reboot-file.hex handy!), copy to clipboard</li>
      <li>On remote system: paste through xxd-reverse pipe, save in
        /dev.</li>
      <li>On remote system: chmod +x the damn thing and run it.</li>
    </ul>
    <p>You can have a script on your system that automates the process.
      I have done this so rarely that I've not bothered writing one.</p>
  </body>
</html>