The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
NAME
    Sys::FreezeThaw - stop and start all user processes on a machine

SYNOPSIS
      use Sys::FreezeThaw;

      Sys::FreezeThaw::freezethaw {
         # run code while system is frozen
      };

      my $token = Sys::FreezeThaw::freeze;
      ... do something ...
      Sys::FreezeThaw::thaw $token;
  
DESCRIPTION
    Operating Systems current supported: Linux-2.6.

    This module implements a very specific feature: stopping(freezing and
    thawing/continuing all user processes on the machine. It works by
    sending SIGSTOP to all processes, parent-process first, so that the wait
    syscall will not trigger on stopped children. Restarting is done in
    reverse order.

    Using the combined function Sys::FreezeThaw::freezethaw is recommended
    as it will catch runtime errors, but stopping and restarting can be dine
    via seperate function calls.

    Sys::FreezeThaw::freezethaw { BLOCK }
        First tries to stop all processes. If successful, runs the given
        codeblock (or code reference), then restarts all processes again. As
        the system is basically frozen during the codeblock execution, it
        should be as fast as possible.

        Runtime errors will be caught with "eval". If an exception occurs it
        will be re-thrown after processes are restarted. If processes cannot
        be frozen or restarted, this function will throw an exception.

        Signal handlers for SIGPIPE, SIGHUP, SIGALRM, SIGUSR1 and SIGUSR2
        will temporarily be installed, so if you want to catch these, you
        have to do so yourself within the executed codeblock.

        Try to do as few things as possible. For example, outputting text
        might cause a deadlock, as the terminal emulator on the other side
        of STDOUT might be stopped, etc.

        The return value of the codeblock is ignored right now, and the
        function doesn't yet return anything sensible.

    $token = Sys::FreezeThaw::freeze;
        Send SIGSTOP to all processes, and return a token that allows them
        to be thawed again.

        If an error occurs, an exception will be thrown and all stopped
        processes will automatically be thawed.

    Sys::FreezeThaw::thaw $token
        Take a token returned by Sys::FreezeThaw::freeze and send all
        processes a CONT signal, in the order required for them not to
        receive child STOP notifications.

BUGS
    SIGCONT is not unnoticed by processes. Some programs (such as
    irssi-text) respond by flickering (IMHO a bug in irssi-text). Other
    programs might have other problems, but actual problems should be rare.
    However, one shouldn't overuse this module.

AUTHOR
       Marc Lehmann <schmorp@schmorp.de>
       http://home.schmorp.de/