This file is indexed.

/usr/share/doc/coop-computing-tools/manual/ftsh.html is in coop-computing-tools-doc 4.0-1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
<html>

<head>
<title>Fault-Tolerant Shell (ftsh) Technical Manual</title>
</head>

<body bgcolor=white>

<h1>Fault-Tolerant Shell (ftsh) Technical Manual</h1>

<b>27 August 2004</b>
<p>
The Fault Tolerant Shell (ftsh) is Copyright (c) 2003-2004 Douglas Thain and 
Copyright (c) 2005 The University of Notre Dame.  All rights reserved.
This software is distributed under the GNU General Public License.
Please see the file COPYING for details.
<p>
<b>Please use the following citation for FTSH:</b>
<dir>
<li> Douglas Thain and Miron Livny, <a href=http://www.cse.nd.edu/~dthain/papers/ethernet-hpdc12.pdf>The Ethernet Approach to Grid Computing</a>, IEEE High Performance Distributed Computing, August 2003.
</dir>

<a name=introduction></a>
<h2>Introduction</h2>

Shell scripts are a vital tool for integrating software.
They are indispensable for rapid prototyping and system assembly.
Yet, they are extraordinarily sensitive to errors.
A missing file, a broken network, or a sick file server can
cause a script to barrel through its actions with surprising results.
It is possible to write error-safe scripts,
but only with extraordinary discipline and complexity.
<p>
The Fault Tolerant Shell (ftsh) aims to solve this problem
by combining the ease of scripting with precise error semantics.
Ftsh is a balance between the flexibility and power of script languages
and the precision of most compiled languages.  Ftsh parses complete
programs in order to eliminate run-time errors.
An exception-like structure allows scripts to be both succinct and safe.
A focus on timed repetition simplifies the most common form of 
recovery in a distributed system.  A carefully-vetted set of language
features limits the "surprises" that haunt system programmers.
<p>
As an example, consider this innocuous script written in Bourne Shell:
<pre>
        #!/bin/sh

        cd /work/foo
        rm -rf bar
        cp -r /fresh/data .
</pre>
Suppose that the <tt>/work</tt> filesystem is temporarily unavailable,
perhaps due to an NFS failure.
The <tt>cd</tt> command will fail and print a message on the console.
The shell will ignore this error result -- it is primarily designed
as a user interface tool -- and proceed to execute the <tt>rm</tt> and
<tt>cp</tt> in the directory it happened to be before.
<p>
Naturally, we may attempt to head off these cases with code that
checks error codes, attempts to recover, and so on.  However,
even the disciplined programmer that leaves no value unturned must
admit that this makes shell scripts incomprehensible:
<pre>
        #!/bin/sh

        for attempt in 1 2 3
               cd /work/foo
               if [ ! $? ]
               then
                       echo "cd failed, trying again..."
                       sleep 5
               else
                       break
               fi
        done

        if [ ! $? ]
        then
               echo "couldn't cd, giving up..."
               return 1
        fi
</pre>
And that's just the first line!
<p>
If we accept that failure, looping, timeouts, and job cancellation
are fundamental concerns in distributed systems, we may both simplify and
strengthen programs by making them fundamental expressions in a programming
language.  These concepts are embodied in the simple <tt>try</tt> command:
<pre>
        #!/usr/bin/ftsh

        try for 5 minutes every 30 seconds
                cd /work/foo
                rm -rf bar
                cp -r /fresh/data .
        end
</pre>
<p>
Ftsh provides simple structures that encourage explicit acknowledgement
of failure while maintaining the readability of script code.  You might
think of this as exceptions for scripts.
<P>
Want to learn more?
This document is a short introduction to the fault tolerant shell.
It quickly breezes over the language features in order to get
started.  You can learn more about the motivation for the language in
<a href=http://www.cse.nd.edu/~ccl/software/ftsh/ethernet-hpdc12.pdf>"The Ethernet Approach to Grid Computing"</a>,
available from the <a href=http://www.cse.nd.edu/~ccl/software/ftsh>ftsh web page</a>
For a quick introduction, read on!

<a name=basics></a>
<h2>Basics</h2>

<h3>Simple Commands</h3>

An ftsh program is built up from simple commands.
A simple command names a program to be executed, just <tt>sh</tt> or <tt>csh</tt>.
The command is separated from its arguments by whitespaces.
Quotation marks may be used to escape whitespace. For example:
<pre>
       ls -l /etc/hosts
</pre>
or:
<pre>
       cat /etc/passwd
</pre>
or:
<pre>
       cp "This File" "That File"
</pre>
<p>
As you may know, a command (a UNIX process) returns an integer known
as its "exit code."  Convention dictates that an exit code of zero
indicates success while any other number indicates failure.  Languages
tend to differ in their mapping of integers to success or failure, so
from here on, we will simply use the abstract terms "success" and "failure."
<p>
A command may also fail in a variety of other ways without returning an
exit code.  It may be killed by a signal, or it may fail to start
altogether if the program does not exist or its image cannot be loaded.
These cases are also considered failures.

<h3>Groups</h3>

A "group" is simply a list of commands.
Each command only runs if the previous command succeeded.
Let's return our first example:
<pre>
        #!/usr/bin/ftsh

        cd /work/foo
        rm -rf bar
        cp -r /fresh/data .
</pre>
This group succeeds only if <b>every command</b> in the group succeeds.
So, if <tt>cd</tt> fails, then the whole group fails and no further commands
are executed.
<p>
This is called the "brittle" property of ftsh.  If anything goes wrong,
then processing stops instantly.  When something goes wrong, you will
know it, and the program will not "run away" executing more commands blindly.
We will see ways to contain the brittleness of a program below.
<p>
Ftsh itself has an exit code.
Ftsh returns the result of the top-level group that makes up the program.
So, if any command in the top-level group fails, then ftsh itself will
fail.  If they all succeed, then ftsh succeeds.

<h3>Try Statements</h3>

A try statement is used to contain and retry group failure.
Here is a simple try statement:
<pre>
        #!/usr/bin/ftsh

        try 5 times
               cd /work/foo
               rm -rf bar
               cp -r /fresh/data .
        end
</pre>

The try statement attempts to execute the enclosed group until
the conditions in its header expire.  Here, the group will
be attempted five times.  Recall that a group fails as soon as any
one command fails.  So, if <tt>rm</tt> fails, then the try statement
will stop and attempt the group again from the beginning.
<p>
If the five times are exceeded, then the try statement itself
fails, and (if it is the top-level try-statement) the whole
shell program itself will fail.  If you prefer, you may
catch and react to a try statement in a manner similar to
an exception.  The <tt>failure</tt> keyword may be used
to cause a new exception, just like <tt>throw</tt> in other languages.
<pre>
        try 5 times
               cd /work/foo
               rm -rf bar
               cp -r /fresh/data .
        catch
               echo "Oops, it failed.  Oh well!"
               failure
        end
</pre>
<p>
Try statements come in several forms.
They may limit the number of times the group is executed.
For example:
<pre>
        try for 10 times
</pre>
A try statement may allow an unlimited number of loops,
terminated by a maximum amount of time, given in seconds,
minutes, hours, or days:
<pre>
        try for 45 seconds
</pre>
Both may be combined, yielding a try statement that stops
when either the loop limit or the time limit expires:
<pre>
        try for 3 days or 100 times
</pre>
Note that such an statement does not limit the length
of any single attempt to execute the contained group.
If a single command is delayed for three days, the try statement
will wait that long and then kill the command.
To force individual attempts to be shorter, try statements
may be nested.  For example:
<pre>
        try for 3 days or 100 times
                try for 1 time or 1 minute
                        /bin/big-simulation
                end
        end
</pre>
Here, <tt>big-simulation</tt> will be executed for
no more than a minute at a time.  Such one-minute attempts
will be tried for up to three days or one hundred attempts
before the outer try statement fails.
<p>
By default, ftsh uses an exponential backoff.
If a group fails once, ftsh will wait one second, and then
try again.  If it fails again, it will wait 2 seconds,
then 4 seconds, and so on, doubling the waiting time after
each failure, up to a maximum of one hour.
This prevents failures from consuming
excessive resources in fruitless retries.
<p>
If you prefer to have the retries occur at regular
intervals (though we don't recommend it)
use the <tt>every</tt> keyword to control
how frequently errors are retried.  For example:
<pre>
        try for 3 days every 1 hour

        try for 10 times every 30 seconds
 
        try for 1 minute or 3 times every 15 seconds
</pre>
If a time limit expires in the middle of a try statement, then
the currently running command is forcibly cancelled.  If an
<tt>every</tt> clause is used, it merely ensures that each attempt
is at <b>least</b> that long.  However, group will not be cancelled
merely to satisfy an <tt>every</tt> clause.  To ensure that a single
loop attempt will be time limited, you may combine two try
statements as above:
<pre>
        try for 3 days or 100 times <b>every 1 minute</b>
                try for 1 time or <b>1 minute</b>
                        /bin/big-simulation
                end
        end
</pre>
Try statements themselves return either success or failure
in the same way as a simple command.
If the enclosed group finally succeeds, then the try
expression itself succeeds. If the try expression exhausts
its attempts, then the try statement itself fails.
We will make use of this success or failure value in the next section.
<p>
Cancelling a process is somewhat more complicated than one might think.
For all the details on how this actually works, see the section
on cancelling processes below.
<p>
In (almost) all cases, a try statement absolutely controls
what comes inside of it.  There are two ways for a subprogram
to break out of the control of a try.  The first is to invoke
<tt>exit</tt>, which causes the entire ftsh process to exit
immediately with the given exit code.  The second is to call
<tt>exec</tt>, which causes the given process to be run
in place of the current shell process, thus voiding any
surrounding controls.

<h3>Redirection</h3>

Ftsh uses Bourne shell style I/O redirection. For example:
<pre>
        echo "hello" &gt; outfile
</pre>
...sends the output <tt>hello</tt> into the file <tt>outfile</tt>,
likewise, ftsh supports many of the more arcane redirections
of the Bourne shell, such as the redirection of explicit file descriptors:
<pre>
        grep needle 0&lt;infile 1&gt;outfile 2&gt;errfile
</pre>
...appending to output files:
<pre>
        grep needle &gt;&gt;outfile 2&gt;&gt;errfile
</pre>
...redirection to an open file descriptor:
<pre>
        grep needle &gt;outfile 2&gt;&amp;1
</pre>
...and redirection of both input and output at once:
<pre>
        grep needle &gt;&amp; out-and-err-file
</pre>

<h2>Variables</h2>

Ftsh provides variables similar to that of the Bourne shell.
For example,
<pre>
        name=Douglas
        echo "Hello, ${name}!"
        echo "Hello, $(name)!"
        echo "Hello, $name!"
</pre>
Ftsh also allows variables to be the source and target
of redirections.  That is, a variable may act as a file!
The benefit of this approach is that ftsh manages the storage
and name space of variables for you.  You don't have to worry
about cleaning up or clashing with other programs.
<p>
Variable redirection looks just like file redirection, except
a dash is put in front of the redirector.  For example,
For example, suppose that we want to capture the output of
<tt>grep</tt> and then run it through <tt>sort</tt>:
<pre>
        grep needle /tmp/haystack -&gt; needles
        sort -&lt; needles
</pre>
This sort of operation takes the place of a pipeline,
which ftsh does not have (yet).  However, by using variables
instead of pipelines, different retry conditions may be
placed on each stage of the work:
<pre>
        try for 5 times
                grep needle /tmp/haystack -&gt; needles
        end
        try for 1 hour
                sort -&lt; needles
        end
</pre>
<p>
All of the variations on file redirection are available for variable
redirection, including -&gt; and 2-&gt; and -&gt;&gt;
and 2-&gt;&gt; and -&gt;&amp; and -&gt;&gt;&amp;.
<p>
Like the Bourne shell, several variable names are reserved.
Simple integers are used to refer
to the command line arguments given to ftsh itself.
<tt>$$</tt> names the current process.
<tt>$#</tt> gives the number of arguments passed to the program.
<tt>$*</tt> gives all of the unquoted current arguments, while
<tt>"$@"</tt> gives all of the arguments individually quoted.
The <tt>shift</tt> command can be used to pop off the
first positional argument.
<p>
Variables are implemented by creating temporary files and immediately unlinking
them after creation.  Thus, no matter how ftsh exits
-- even if it crashes -- the kernel deletes buffer space after you.
This prevents both the namespace and garbage
collection problem left by scripts that manually read and write to files.

<a name=structures></a>
<h2>Structures</h2>

Complex programs are built up by combining basic elements
with programming structures.  Ftsh has most of the decision
elements of other programming languages, such as conditionals
and loops.  Each of these elements behaves in a very precise way with
respect to successes and failures.

<h3>For-Statements</h3>

A for-statement executes a command group once for each
word in a list.  For example:

<pre>
        for food in bread wine meatballs
                echo "I like ${food}"
        end
</pre>

Of course, the list of items may also come from a variable:

<pre>
        packages="bread.tar.gz wine.tar.gz meatballs.tar.gz"

        for p in ${packages
                echo "Unpacking package ${p}..."
                tar xvzf ${p}
        end
</pre>

The more interesting variations are <tt>forany</tt> and <tt>forall</tt>.
A <tt>forany</tt> attempts to make a group succeed once for any of the options given
in the header, chosen randomly.  After the for-statement has run, the branch that
succeeds in made available through the control variable:
<pre>
        hosts="mirror1.wisc.edu mirror2.wisc.edu mirror3.wisc.edu"
        forany h in ${hosts}
                echo "Attempting host ${host}"
                wget http://${h}/some-file       
        end
        echo "Got file from ${h}"
</pre>

A <tt>forall</tt> attempts to make a group succeed for all of the options
given in the header, simultaneously:
<pre>
        forall h in ${hosts}
                ssh ${h} reboot
        end
</pre>

Both <tt>for</tt> and <tt>forall</tt> are brittle with respect to failures.
If any instance fails, then the entire for-statement
fails.  A try-statement may be added in one of two ways.
If you wish to make each iteration resilient, place
the try-statement inside the for-statement:

<pre>
        for p in ${packages}
                try for 1 hour every 5 minutes
                        echo "Unpacking package ${p}..."
                        tar xvzf ${p}
                end
        end
</pre>

Or, if you wish to make the entire for-statement
restart after a failure, place it outside:

<pre>
        try for 1 hour every 5 minutes
                for p in ${packages}
                        echo "Unpacking package ${p}..."
                        tar xvzf ${p}
                end
        end
</pre>

<h3>Loops, Conditionals, and Expressions</h3>

Ftsh has loops and conditionals similar to other languages.
For example:
<pre>
        n=0
        while $n .lt. 10
                echo "n is now ${n}"
                n=$n .add. 1
        end
</pre>
And:
<pre>
        if $n .lt. 1000
                echo "n is less than 1000"
        else if $n .eq. 1000
                echo "n is equal to 1000"
        else
                echo "n is greater than 1000"
        end
</pre>

You'll notice right away that arithmetic expressions look a little
different than other languages.
Here's how it works:
<p>
The arithmetic operators .add. .sub. .mul. .div. .mod. .pow.
represent addition, subtraction, multiplication, division, modulus,
and exponentiation, including parenthesis and the usual order
of operations.  For example:
<pre>
        a=$x .mul. ( $y .add. $z )
</pre>
The comparison operators .eq. .ne. .le. .lt. .ge. .gt
represent equal, not-equal, less-than-or-equal, less-than,
greater-than-or-equal, and greater-than.  These return
the literal strings "true" and "false".
<pre>
        uname -s -> n
        if $n .ne. Linux
                ...
        end

</pre>
For integer comparison, use the operators .eql. and .neql..
<pre>
	if $x .eql. 5
		...
	end
</pre>
The Boolean operators .and. .or .not. have the usual meaning.
An exception is thrown if they are given arguments that are
not the boolean strings "true" or "false".
<pre>
        while ( $x .lt. 10 ) .and. ( $y .gt. 20 )
                ...
        end
</pre>
The unary file operators .exists. .isr. .isw. .isx. test whether
a filename exists, is readable, writeable, or executable, respectively.
The similar operators .isfile. .isdir. .issock. .isfile. .isblock. .ischar.
test for the type of a named file.
All these operators throw exceptions if the named file is unavailable
for examination.
<pre>
        f=/etc/passwd
        if ( .isfile. $f ) .and. ( .isr. $f )
                ...
        end
</pre>
Finally, the .to. and .step. operators are conveniences for generating
numeric lists to be used with for-loops:
<pre>
        forall x in 1 .to. 100
                ssh c$x reboot
        end

        for x in 1 .to. 100 .step. 5
                y=$x .mul. $x
                echo "$x times $x is $y"
        end
</pre>

Notice that, unlike other shells, there is a distinction
between expressions, which compute a value or throw an
exception, and external commands, which return no value.
Therefore, you cannot do this:
<pre>
        # !!! This is wrong !!!
        if rm $f
                echo "Removed $f"
        else
                echo "Couldn't remove $f"
        end
</pre>
Instead, you want this:
<pre>
        try
                rm $f
                echo "Removed $f"
        catch
                echo "Couldn't remove $f"
        end
</pre>

<h3>Functions</h3>

Simple functions are named groups of commands that may
be called in the same manner as an external program.
The arguments passed to the function are available
in the same way as arguments to the shell:

<pre>
function compress_and_move
        echo "Working on ${1}..."
        gzip ${1}
        mv ${1}.gz ${2}
end

compress_and_move /etc/hosts /tmp/hosts.gz
compress_and_move /etc/passwd /tmp/passwd.gz
compress_and_move /usr/dict/words /tmp/dict.gz
</pre>

A function may also be used to compute and return
a value:

<pre>
function fib
	if $1 .le. 1
		return 1
	else
		return fib($1 .sub. 1) .add. fib($1 .sub. 2)
	end
end

value=fib(100)
echo $value
</pre>

Functions, like groups, are brittle with respect
to failures.  A failure inside a function causes
the entire function to stop and fail immediately.
As in most languages, functions may be both nested
and recursive.  However, ftsh aborts recursive
function calls deeper than 1000 steps.
If a function is used in an expression but does not
return a value, then the expression evaluation fails.

<a name=miscellaneous></a>
<h2>Miscellaneous Features</h2>

<h3>Environment</h3>
Variables may be exported into the environment, just like the Bourne shell:
<pre>
        PATH="/usr/bin:/usr/local/bin"
        export PATH
</pre>

<h3>Nested Shells</h3>

Ftsh is perfectly safe to nest.
That is, an ftsh script may safely call other scripts written in ftsh.
One ftsh passes all of its options to sub-shells using environment
variables, so logs, error settings, and timeouts are uniform from
top to bottom.  If a sub-shell provides its own arguments, these
override the environment settings of the parent.

<h3>Error Logging</h3>

Ftsh may optionally keep a log that describes all the details
of a script's execution.  The -f option specifies a log file.
Logs are open for appending, so parallel and sub-shells may
share the same log. The time, process number, script, and
line number are all recorded with every event.
<p>
<b>Note: Logs shared between processes must not be recorded in NFS or AFS filesystems.
NFS is not designed to support shared appending: your logs
will be corrupted sooner or later.  AFS is not designed to support
simultaneous write sharing of a file: you will end up with the
log of one process or another, but not both.  These are deliberate
design limitations of these filesystems and are not bugs in
UNIX or ftsh.
</b>
<p>
The amount of detail kept in a log
is controled with the -l option.  These logging
levels are currently defined:
<ul>
<li><b>0</b> - Nothing is logged.
<li><b>10</b> - Display failed commands and structures.
<li><b>20</b> - Display executed commands and their exit codes.
<li><b>30</b> - Display structural elements such as TRY and IF-THEN.
<li><b>40</b> - Display process activities such as signals and completions. 
</ul>

<h3>Command-Line Arguments</h3>
Ftsh accepts the following command-line arguments:
<ul>
<li> <b>-f &lt;file&gt;</b> The name of a log file for tracing the
execution of a script.  This log file is opened in append mode.
Equivalent to the environment variable FTSH_LOG_FILE.
<li> <b>-l &lt;level&gt;</b> The logging level, on a scale of 0 to 100.
Higher numbers log more data about a script.
Equivalent to the environment variable FTSH_LOG_LEVEL.
<li> <b>-k &lt;mode&gt;</b> - Controls whether ftsh trusts the operating
system to actually kill a process.  If set to 'weak', ftsh will assume
that processes die without checking.  If set to 'strong', ftsh will issue
SIGKILL repeatedly until a process actually dies.
Equivalent to the environment variable FTSH_KILL_MODE.
<li> <b>-t &lt;secs&gt;</b> - The amount of time ftsh will wait
between requesting a process to exit (SIGTERM) and killing it forcibly (SIGKILL).
Equivalent to the environment variable FTSH_KILL_TIMEOUT.
<li> <b>-p</b> Parse, but do not execute the script.  This option may be used to test the validity of an Ftsh script.
<li> <b>-v</b> Show the version of ftsh.
<li> <b>-h</b> Show the help screen.
</ul>

<h3>Cancelling Processes</h3>

Cancelling a running process in UNIX is rather quite complex.
Although starting and stopping one single process is fairly
easy, there are several complications to manging a tree of
processes, as well as dealing with the various failures that
can occur in the transmission of a signal.
<p>
Ftsh can clean up any set of processes that it starts,
given the following restrictions:
<dir>
<li> Your programs must not create a new UNIX "process session"
with the <tt>setsid()</tt> system call.  If you don't know what
this is, then don't worry about it.
<li> The operating system must actually kill a process when
ftsh asks it to.  Some variants of Linux won't kill processes
using distributed file systems.  Consider using the "weak" mode
of ftsh.
<li> Rogue system administrators must not forcibly kill 
an ftsh with a SIGKILL.  However, you may safely send a SIGTERM, SIGHUP,
SIGINT, or SIGQUIT to an ftsh, and it will clean up its children and exit.
</dir>
<p>
Ftsh starts every command as a separate UNIX process in its
own process session (i.e. <tt>setsid</tt>).
This simplifies the administration of
large process tress.  To cancel a command, ftsh sends a SIGTERM
to every process in the group.  Ftsh then waits up to
thirty seconds for the child to exit willingly.  At the end of 
that time, it forcibly terminates the entire process group
with a SIGKILL.
<p>
Surprisingly, SIGKILL is not always effective.
Some operating systems have bugs in which signals
are occasionally lost or the process may be in such
a state that it cannot be killed at all.
By default, ftsh tries very hard to kill processes
by issuing SIGKILL repeatedly until the process actually
dies.  This is called the "strong" kill mode.
If you do not wish to have this behavior -- perhaps
you have a bug resulting in unkillable processes --
then you may run ftsh in the "weak" kill mode, using
the "-k weak" option.
<p>
Ftsh may be safely nested.  That is, an ftsh may invoke
another program written using ftsh.  However, this child
needs to clean up faster than its parents.  If the parent
shell issues forcible kills after waiting for 30 seconds,
then the child must issue forcible kills before that.
This problem is handled transparently for you.
Each ftsh informs its children of the current kill timeout
by setting the FTSH_KILL_TIMEOUT variable to five seconds
less than the current timeout.  Thus, subshells are progressively
less tolerant of programs that refuse to exit cleanly.

<hr>

</body>

</html>