ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Sys-FreezeThaw/README
(Generate patch)

Comparing cvsroot/Sys-FreezeThaw/README (file contents):
Revision 1.1 by root, Sat Oct 5 17:51:34 2013 UTC vs.
Revision 1.2 by root, Mon Oct 7 04:21:18 2013 UTC

9 }; 9 };
10 10
11 my $token = Sys::FreezeThaw::freeze; 11 my $token = Sys::FreezeThaw::freeze;
12 ... do something ... 12 ... do something ...
13 Sys::FreezeThaw::thaw $token; 13 Sys::FreezeThaw::thaw $token;
14 14
15DESCRIPTION 15DESCRIPTION
16 Operating Systems current supported: Linux-2.6. 16 Operating Systems/Kernels current supported: Linux-2.6/3.0 with /proc.
17 17
18 This module implements a very specific feature: stopping(freezing and 18 This module implements a very specific feature: stopping(freezing and
19 thawing/continuing all user processes on the machine. It works by 19 thawing/continuing all userspace processes on the machine. It works by
20 sending SIGSTOP to all processes, parent-process first, so that the wait 20 sending SIGSTOP to all processes, parent-process first, so that the wait
21 syscall will not trigger on stopped children. Restarting is done in 21 syscall will not trigger on stopped children. Restarting is done in
22 reverse order. 22 reverse order.
23 23
24 Using the combined function Sys::FreezeThaw::freezethaw is recommended 24 Using the combined function Sys::FreezeThaw::freezethaw is recommended
25 as it will catch runtime errors, but stopping and restarting can be dine 25 as it will catch runtime errors, but stopping and restarting can be dine
26 via seperate function calls. 26 via separate function calls.
27
28 What could it possibly be sueful for??
29 Possible uses include: doing atomic file system operations (such as
30 replacing files while they are guaranteed not to be in use), or quieting
31 down a system to investigate suspicious behaviour.
27 32
28 Sys::FreezeThaw::freezethaw { BLOCK } 33 Sys::FreezeThaw::freezethaw { BLOCK }
29 First tries to stop all processes. If successful, runs the given 34 First tries to stop all processes. If successful, runs the given
30 codeblock (or code reference), then restarts all processes again. As 35 code block (or code reference), then restarts all processes again.
31 the system is basically frozen during the codeblock execution, it 36 As the system is basically frozen during the code block execution,
32 should be as fast as possible. 37 it should be as fast as possible.
33 38
34 Runtime errors will be caught with "eval". If an exception occurs it 39 Runtime errors will be caught with "eval". If an exception occurs it
35 will be re-thrown after processes are restarted. If processes cannot 40 will be re-thrown after processes are restarted. If processes cannot
36 be frozen or restarted, this function will throw an exception. 41 be frozen or restarted, this function will throw an exception.
37 42
38 Signal handlers for SIGPIPE, SIGHUP, SIGALRM, SIGUSR1 and SIGUSR2 43 Signal handlers for SIGINT, SIGTERM, SIGPIPE, SIGHUP, SIGALRM,
39 will temporarily be installed, so if you want to catch these, you 44 SIGUSR1 and SIGUSR2 will be installed temporarily, so if you want to
40 have to do so yourself within the executed codeblock. 45 catch these, you have to do so yourself within the executed code
46 block.
41 47
42 Try to do as few things as possible. For example, outputting text 48 Try to do as few things as possible. For example, outputting text
43 might cause a deadlock, as the terminal emulator on the other side 49 might cause a deadlock, as the terminal emulator on the other side
44 of STDOUT might be stopped, etc. 50 of STDOUT might be stopped, logging to syslog might not work and so
51 on.
45 52
46 The return value of the codeblock is ignored right now, and the 53 The return value of the code block is ignored right now, and the
47 function doesn't yet return anything sensible. 54 function doesn't yet return anything sensible.
48 55
49 $token = Sys::FreezeThaw::freeze; 56 $token = Sys::FreezeThaw::freeze
50 Send SIGSTOP to all processes, and return a token that allows them 57 Send SIGSTOP to all processes, and return a token that allows them
51 to be thawed again. 58 to be thawed again.
52 59
53 If an error occurs, an exception will be thrown and all stopped 60 If an error occurs, an exception will be thrown and all stopped
54 processes will automatically be thawed. 61 processes will automatically be thawed.
55 62
56 Sys::FreezeThaw::thaw $token 63 Sys::FreezeThaw::thaw $token
57 Take a token returned by Sys::FreezeThaw::freeze and send all 64 Take a token returned by Sys::FreezeThaw::freeze and send all
58 processes a CONT signal, in the order required for them not to 65 processes a "CONT" signal, in the order required for them not to
59 receive child STOP notifications. 66 receive child STOP notifications.
67
68 $Sys::FreezeThaw::PARTIAL_OK
69 A boolean that tells "freeze" whether it is an error if a process
70 cannot be stopped. If false (the default), then "freeze" will fail
71 if there is an unstoppable process. If it is true, then "freeze"
72 will pretend it the process stopped.
60 73
61BUGS 74BUGS
62 SIGCONT is not unnoticed by processes. Some programs (such as 75 SIGCONT is not unnoticed by processes. Some programs (such as
63 irssi-text) respond by flickering (IMHO a bug in irssi-text). Other 76 irssi-text) respond by flickering (IMHO a bug in irssi-text). Other
64 programs might have other problems, but actual problems should be rare. 77 programs might have other problems, but actual problems should be rare.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines