The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-01-2007
Registered User
 

Join Date: Nov 2006
Posts: 15
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.
Reply With Quote
Forum Sponsor
  #2  
Old 05-02-2007
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,636
Use a trap on SIGINT and use a cleanup function to kill the child.
Reply With Quote
  #3  
Old 05-02-2007
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
Question Duplicate?

Isnt this a duplicate post?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0