Sponsored Content
Top Forums Shell Programming and Scripting Killing an Xterm while leaving subprocess alive... Post 87282 by mschwage on Friday 21st of October 2005 09:40:20 PM
Old 10-21-2005
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check if job still alive and killing it after a certain walltime

Hi! I'm using a script to start a process that might run forever if some parameters are given wrong (it's part of an optimization). I would now like to have the process killed after a certain walltime in that case. So far I get it done with the following lines ./My_process.e & pid=`ps -ef |... (3 Replies)
Discussion started by: ciwstevie
3 Replies

2. Shell Programming and Scripting

Leaving Program running but killing the script

Sorry for all the threads. I am almost done. I ahve a bash script that is launching a diags program then copying the .html over my client. then it does the following line /opt/firefox/firefox report.html it launches it fines but the program waits for me to close the window or kill the script.... (2 Replies)
Discussion started by: deaconf19
2 Replies

3. Shell Programming and Scripting

Doubt about pipes and subprocess

Hi, I am having a trivial doubt. Please see the below pipeline code sequence. command1 | (command 2; commend 3) I am aware that the command that follows pipe will run in the sub shell by the Unix kernel. But how about here? Since these set of commands are grouped under "parantheses", will... (6 Replies)
Discussion started by: royalibrahim
6 Replies

4. Shell Programming and Scripting

Finding the age of a unix process, killing old processes, killing zombie processes

I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time. Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies

5. AIX

Subprocess errors

Hi Guys, Just a question about subprocesses.. Lately one of our servers has started to throw out the following error: SYSTEM ERROR: Too many subprocesses, cannot fork. Errno=12 We've already increased the threshold twice. Its now up to 8000 and the swap space has also been increased. We... (6 Replies)
Discussion started by: Jazmania
6 Replies

6. Shell Programming and Scripting

Xterm using python subprocess

Hi, I am trying to run a shell script using subprocess in python. I can run simple script with arguments using subprocess.But I am not able to embed xterm in subrocess command. #!/usr/bin/python import subprocess subprocess.call() Above code gives me error. Please help me in... (2 Replies)
Discussion started by: diehard
2 Replies

7. Shell Programming and Scripting

Python subprocess

Hi guys, I'm learning python and perl and i was trying to run from python a perl script using the subprocess module. I have an issue that i don't understand regarding this. I run this code: #!/usr/bin/python import subprocess p2 = subprocess.Popen(,stdout=subprocess.PIPE) output2 =... (2 Replies)
Discussion started by: capitanui
2 Replies

8. UNIX for Advanced & Expert Users

Trapping a kill command sent to a script and using it to send an EOF to a subprocess before killing

I originally had a script written in pure shell that I used to parse logs in real time and create a pipe delimited file that only contained errors. It worked but it was using a lot of memory (still not clear on why). I originally got around this by writing a wrapper for the script that ran on cron... (1 Reply)
Discussion started by: DeCoTwc
1 Replies

9. Shell Programming and Scripting

Python3 subprocess troubles

After struggling with this for days now, I'm reaching out to the experts of all things linux for some help with this. I'm trying to run the following working command (on command line) inside a python script using subprocess: rsync -avzh --no-perms --delete --include="*sub*" --exclude='*'... (2 Replies)
Discussion started by: timj123
2 Replies

10. Programming

[Python] - subprocess issue

So I have this basic script, see below import subprocess import shlex command = "gcloud projects list" subprocess.check_output(shlex.split(command)) subprocess.check_call(shlex.split(command)) The subprocess.check_call(shlex.split(command)) actually return what I expect. It returns... (6 Replies)
Discussion started by: scj2012
6 Replies
Courier::Filter::Module::Envelope(3pm)			User Contributed Perl Documentation		    Courier::Filter::Module::Envelope(3pm)

NAME
Courier::Filter::Module::Envelope - Message envelope filter module for the Courier::Filter framework SYNOPSIS
use Courier::Filter::Module::Envelope; my $module = Courier::Filter::Module::Envelope->new( fields => { # One or more of the following fields: sender => 'paul.greenfield@unisys.com', recipient => 'julian@mehnle.net', remote_host => '216.250.130.2', remote_host_name => qr/(^|.)php.net$/, remote_host_helo => qr/^[^.]*$/ }, # Optionally the following: response => $response_text, logger => $logger, inverse => 0, trusting => 0, testing => 0, debugging => 0 ); my $filter = Courier::Filter->new( ... modules => [ $module ], ... ); DESCRIPTION
This class is a filter module class for use with Courier::Filter. It matches a message if one of the message's envelope fields matches the configured criteria. Constructor The following constructor is provided: new(%options): returns Courier::Filter::Module::Envelope Creates a new Envelope filter module. %options is a list of key/value pairs representing any of the following options: fields Required. A reference to a hash containing the message envelope field names and patterns (as key/value pairs) that messages are to be matched against. Field names are matched case-insensitively. Patterns may either be simple strings (for exact, case-sensitive matches) or regular expression objects created by the "qr//" operator (for inexact, partial matches). The following envelope fields are supported: sender The message's envelope sender (from the "MAIL FROM" SMTP command). recipient Any of the message's envelope recipients (from the "RCPT TO" SMTP commands). remote_host The IP address of the SMTP client that submitted the message. remote_host_name The host name (gained by Courier through a DNS reverse lookup) of the SMTP client that submitted the message, if available. remote_host_helo The HELO string that the SMTP client specified, if available. So for instance, to match any message with a sender of "paul.greenfield@unisys.com", directed at "julian@mehnle.net" (possibly among other recipients), you could set the "fields" option as follows: fields => { sender => 'paul.greenfield@unisys.com', recipient => 'julian@mehnle.net' } response A string that is to be returned literally as the match result in case of a match. Defaults to "Prohibited <field>: <value>". All options of the Courier::Filter::Module constructor are also supported. Please see "new()" in Courier::Filter::Module for their descriptions. Instance methods See "Instance methods" in Courier::Filter::Module for a description of the provided instance methods. SEE ALSO
Courier::Filter::Module::Header, Courier::Filter::Module, Courier::Filter::Overview. For AVAILABILITY, SUPPORT, and LICENSE information, see Courier::Filter::Overview. AUTHOR
Julian Mehnle <julian@mehnle.net> perl v5.14.2 2011-12-27 Courier::Filter::Module::Envelope(3pm)
All times are GMT -4. The time now is 05:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy