Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General ksh question

Status
Not open for further replies.

nandamuri

Programmer
Feb 26, 2002
15
US

I have a script test.sh. I am trying to add traps to this script. This script invokes installp. installp takes around 5 mins to complete. After installp i have some 30 lines of shell commands. So when i send a signal like "CTRL+C" when the script is executing installp line, the installp process is stopping. How can i avoid this.

Basically how can i trap a signal sent to parent process shell script when it is executing a child process with out stopping the child process.
Example code:
#!/bin/ksh

trap 'cannot stop the execution' 1 2 3 15
# Do some thing for the next 20 lines
installp -qagcX blah
# Do some more for the next 20 lines.

# End of script

NOw if we send "CTRL+C" in the shell that the above script is being executed when the script is executing installp i want the installp to continue without any problem.

Note:The script may contain some syntax errors.
Any help is appreciated

TIA
kant
 
Try simply trap "" 1 2 3 15.

It seems in my testing that defining any commands to be executed upon receipt of that signal (as opposed to the null string) results in the trap being propagated to the child process anyway. Does anyone know how to avoid this?

If someone types Ctrl-C, do you still want the parent script to be interrupted while installp continues? Annihilannic.
 
Basically i want the parent script and child process to continue even when a signal is received like CTRL+C.
 
Ho come i am not able to stop the signal 18 which is "CTRL+Z". When i send this signal the parent process is going into background. How can i avoid this.

Anninilannic,
Your suggestion worked for CTRL+C and CTRL+\. Thanks.
 
Nandamuri:

I'm guessing that control-z is being used for suspending operation. Execute stty -a and you should see

susp=^z

On my solaris 7 box, I set susp to something else by placing this line in /etc/profile:

stty susp ^@

Regards,

Ed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top