--killing backround Procs spawned from the parent script with Ctrl+C trap
Hello:
Am trying to understand why the method #2 works but method #1 does not.
For both methods, sending CTRL+C should kill both the Parent script & all of the spanwd background procs.
Method #1:
==========================
Method #2:
=========================
So for method #1, the spawned BG Procs have init as the PPID.
so even the "sudo kill -9" does not kill them
for method #2, we are using "kill 0", but this works.
But "kill 0" does not actually kill but :
"If sig is 0, then no signal is sent, but error checking is still performed."
So looks like Method #2 works solely because the whole thing is executed
from the Sub-Shell.
Curiously, the additional commands like "echo $TEST_PARALLEL_1 $TEST_PARALLEL_2"
did not show on the STDOUT.
Just trying to better understand the whole process.
Hi,
Just wonder if there is a way to identify the PID of the killing process using trap.
Please let me know possible solution.
#!/bin/ksh
hello () {
print "in hello";
print "PID of process issued SIGNAL"; --> this is what i'm looking for.
}
trap hello SIGKILL SIGTERM
while... (3 Replies)
Hi All,
Although each line below seems to work by itself, I've been having trouble getting the Control-C trap working when I add the "|perl -pe..." to the end of the tail -f line, below.
(That |perl -pe statement basically just adds color to highlight the word "ERROR" while tailing a log... (2 Replies)
I am needing to call sqlplus and sqlldr in the same korn shell script. Below are the steps that I need to accomplish. I am new to Oracle shell scripting so an example would be great.
CBOB_LOAD.KSH - script name
Calls Oracle stored procedure sp_CBOB_CLEAR_LN_STAGING (SERVER: TESTSVR100)
Calls... (0 Replies)
Hello,
I have a script which copies via scp several large files to a remote server. What I want is that even if someone hits CTRL-C, the scp commands continues till the end.
Here is what I wrote
#! /bin/bash
function testFunction
{
echo "COPY START"
scp large.tar.gz... (11 Replies)
I am trying to trap CTRL-C, now the program I call has it's own exit message, I think this is the problem ..
This is what I have now :
function dothis
{
echo 'you hit control-c'
exit
}
function settrap
{
trap dothis SIGINT
}
settrap
until false; do
./ITGRecv.exe
doneDoing this I... (2 Replies)
Hi all,
I am writing a script which calls other third party scripts that perform numerous actions. I have no control over these scripts.
My problem is, one of these scripts seems to execute and do what it is meant to do, but my calling / parent script always exits at that point. I need to... (4 Replies)
how to trap the ctrl c in unix shell script
my script is running in while loop it should not be terminate with ctrl c.
if i press ctrl c while running script it shloud ignore the same.
please healp..........
thanks in advance (2 Replies)
Hi all,
I have a shell script which calls other shell scripts, depending on the input.
Within a.sh, I have a command which calls b.sh (ie. ksh b.sh)
Normally, we use the exit function to terminate a shell. However, if I choose to call exit from b.sh, I will return to the parent shell who... (4 Replies)
Hi everybody,
I'm having some problems wiriting a program in UNIX using the "fork" and "kill" system calls.
I have to create a C program P0, which creates 9 other processes
P1, P2, ..., P9, where P0 is the father of P1, P1 the father of P2, and so on.
All the processes contain an infinite... (0 Replies)
I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)