>> Can you arrange for script B to write a file after it has done "a few
>> things"? Then you can do something like
>> script_B &
>> until [ -f done_it ]; do
>> sleep 1
>> done
>> rm done_it
>Just curious: Can this be done with signals? In particular, can a trapped
>signal break out of a loop, like this
>trap "break" USR1
>script_B &
>while true; do
> sleep 1
>done
>(assuming script_B does `kill -USR1 $$PPID` at some point)?
You can do this in a bourne shell, and it is the natural solution
you could use a flag variable instead of 'break' for the general
case of polling whenever you like for the state of the 2nd task;
~~~~~~~~~main
#!/bin/sh
trap 'task2flag=1' USR1
task2flag=0
_PPID=$$
export _PPID
./script2&
while true
do
[ $task2flag -eq 1 ] && break
echo task1 doing some stuff...
sleep 1
done
echo task2 completed
~~~~~~~~~script2
#!/bin/sh
sleep 10
kill -USR1 $_PPID
~~~~~~~~~
However C-Shell can't do this, if you really must script in
C-Shell you're stuck with the files solution or maybe an
unreliable grepping of 'ps';
From 'Csh Programming Considered Harmful'
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
3. SIGNALS
In the csh, all you can do with signals is trap SIGINT. In the Bourne
shell, you can trap any signal, or the end-of-program exit. For example,
to blow away a tempfile on any of a variety of signals:
$ trap 'rm -f /usr/adm/tmp/i$$ ;
echo "ERROR: abnormal exit";
exit' 1 2 3 15
$ trap 'rm tmp.$$' 0 # on program exit
>--
bestwishes
--
# if you are bored crack my sig.
1F8B0808CABB793C0000666667002D8E410E83300C04EF91F2877D00CA138A7A
EAA98F30C494480157B623C4EF1B508FDED1CEFA9152A23DE35D661593C5318E
630C313CD701BE92E390563326EE17A3CA818F5266E4C2461547F1F5267659CA
8EE2092F76C329ED02CA430C5373CC62FF94BAC6210B36D9F9BC4AB53378D978
80F2978A1A6E5D6F5133B67B6113178DC1059526698AFE5C17A5187E7D930492