Debian Codegraph @

spawn.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # spawn.sh
3
4
5 PIDS=$(pidofscip-shell system . . pidof. sh $0) # Process IDs of the various instances of this script.
6 P_array=( $PIDS ) # Put them in an array (why?).
7 echoscip-shell system . . echo. $PIDS # Show process IDs of parent and child processes.
8 let "instances = ${#P_array[*]} - 1" # Count elements, less 1.
9 # Why subtract 1?
10 echoscip-shell system . . echo. "$instances instance(s) of this script running."
11 echoscip-shell system . . echo. "[Hit Ctl-C to exit.]"; echoscip-shell system . . echo.
12
13
14 sleepscip-shell system . . sleep. 1 # Wait.
15 shscip-shell system . . sh. $0 # Play it again, Sam.
16
17 exit 0 # Not necessary; script will never get to here.
18 # Why not?
19
20 # After exiting with a Ctl-C,
21 #+ do all the spawned instances of the script die?
22 # If so, why?
23
24 # Note:
25 # ----
26 # Be careful not to run this script too long.
27 # It will eventually eat up too many system resources.
28
29 # Is having a script spawn multiple instances of itself
30 #+ an advisable scripting technique.
31 # Why or why not?