It is currently Tue, 30 Nov 2021 17:51:17 GMT



 
Author Message
 subprocess exits with status 2, and sh script stops
I'm writing a /bin/sh script that calls lynx to run a menu system.  If
lynx exits normall, the script continute, and if lynx exits with status
1, the script continues.  But if the user kill lynx with control-c, the
script that calls it dies.

How can I prevent this?

I've tried to rtfm, but I'm not as good as I'd like to be at finding
stuff like this.

Thanks..,



 Wed, 24 Sep 1997 03:00:00 GMT   
 subprocess exits with status 2, and sh script stops

Try the following:

#!/bin/sh

# ignore signal INT (#2),
# thus preventing the shell script from dying
# (typing the interrupt character sends the signal SIGINT to
# all processes in the current foreground job's process
# group).

trap "" 2

# do something before call to lynx

# ...

# before calling lynx, install a trap for SIGINT, because
# keeping it being ignored would make lynx uninterruptible
# by SIGINT also.

trap ":" 2

# call lynx - because SIGINT is not ignored but caught,
# lynx is interruptable by SIGINT look at manual page sh(1),
paragraph "Special Commands", command trap

lynx

# ignore SIGINT again

trap "" 2

# do something after lynx...

# ...

# end of script

Hope that helps.

Shalom, Friedhelm.



 Mon, 29 Sep 1997 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. exit status of pipeline in sh/csh

2. exit status of a shell script called from system()

3. mail causes sh/csh/tcsh scripts to exit


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software