The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to wait for the subprocess to finish in tcl nathgopi214 Shell Programming and Scripting 1 03-26-2008 05:40 AM
Leaving Program running but killing the script deaconf19 Shell Programming and Scripting 2 11-15-2007 10:17 PM
Getting value of variable set in subprocess script hadarot Shell Programming and Scripting 1 08-11-2005 11:41 PM
check if job still alive and killing it after a certain walltime ciwstevie Shell Programming and Scripting 3 07-27-2005 04:04 AM
Multiple FTP scripts submitted to a subprocess tomstone_98 UNIX for Advanced & Expert Users 0 02-11-2005 07:11 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-21-2005
Registered User
 

Join Date: Jul 2005
Location: Chicago, IL
Posts: 93
Killing an Xterm while leaving subprocess alive...

Hi,
I'm not quite understanding what I'm doing (happens often). This pseudocode works:

#!/bin/pseudoksh

function kill_parent {
when i_want_to ; do
sleep 2
kill -TERM $PPID
exit
done
}

kill_parent &
ssh remote_host sh <<-EOF
notify_kill_parent # let the bg function know it's ok to kill parent
run_command # something x-based
EOF


Now, if I start my script in an xterm:
xterm -e run_my_script
It works as expected! The xterm pops up, ssh queries me for a password, the command runs and displays, and, seconds later, the xterm is killed. This is what I want to have happen. But I'm not sure why the remote shell and my application (run_command, above) still stick around. I've been pretty sloppy with stdin/stdout so I'm surprised they don't disappear when I kill the parent (xterm).

I'm happy it works, but I'm worried about a bug creeping in later- for example, since I'm not handling stdout, am I in danger of filling a buffer that is going to make the app hang? Or something like this.

I'm looking for insight into what happens when xterm calls ssh which calls a shell which calls a command. Xterm dies but the command does not. Why?
Thanks.
-Schwage
Reply With Quote
Google UNIX.COM
Forum Sponsor
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:01 PM.


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

Content Relevant URLs by vBSEO 3.2.0