![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing a variable from a child script back to the parent | Andy82 | Shell Programming and Scripting | 3 | 05-26-2008 06:52 PM |
| Parent/child Korn shell script help | sasaliasim | Shell Programming and Scripting | 1 | 05-06-2008 02:09 PM |
| terminating script with CTRL+D | sanchopansa | Shell Programming and Scripting | 12 | 10-26-2006 01:22 AM |
| How to know parent script name from child script | raki | Shell Programming and Scripting | 2 | 06-05-2006 05:01 AM |
| return valuse from child script to parent script | borncrazy | Shell Programming and Scripting | 1 | 08-20-2004 12:39 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Terminating child script without terminating the parent script
Hi
I was working on a shell script with randomly shows a page of text from a randomly selected topic .As soon as the page is displayed it callers a timer script which keeps on running indefinitely until the timer script is killed by the user. This is where I have the problem,if I press Cntrl-C then even the parent script gets terminated.This is what my code looks like cat ${file_nm} |head -$line_count | tail -100 timer.ksh I tried modifying it to try the get the PID of the timer script and kill it like this below if the user enters 0 ,but even that doesn't seem to work cat ${file_nm} |head -$line_count | tail -100 bg timer.ksh PID=$$ echo $PID read kill_proc if [[ $kill_proc -eq 0 ]] then kill $PID fi I tried something like this but even this doesn't seem to work ,can you give me suggestions to just kill the timer script interactively which terminating the parent script as well The timer script is just a simple infinite while loop while true do sleep 1 done Thanks for any help Mervin Johnsingh Last edited by mervin2006; 05-01-2007 at 11:01 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Use a trap on SIGINT and use a cleanup function to kill the child.
|
|
#3
|
|||
|
|||
|
Isnt this a duplicate post?
|
|||
| Google The UNIX and Linux Forums |