SEGV not killing child process of shell script

SEGV not killing child process of shell script

Post by dest » Sun, 16 Jun 2002 04:38:20



I have a shell script (ksh) that sources some stuff then starts a
process.

The process is run in the foreground so it waits for the process to
complete. The problem I'm having is that if you send a kill -10 (BUS)
signal to the shell script process - the script and child both die
correctly.

However - If I send a kill -11 (SEGV) signal to the script pid then
the script dies but the child is left running.

Anyone know what the reason is for this?

Thanks,

Darrell

 
 
 

SEGV not killing child process of shell script

Post by Barry Margoli » Sun, 16 Jun 2002 05:06:02




>I have a shell script (ksh) that sources some stuff then starts a
>process.

>The process is run in the foreground so it waits for the process to
>complete. The problem I'm having is that if you send a kill -10 (BUS)
>signal to the shell script process - the script and child both die
>correctly.

I just tried this and the child process didn't die.

tools:~#189% ./test.ksh &
[1] 10612
tools:~#191% ps t pts/8
   PID TT       S  TIME COMMAND
   487 pts/8    S  0:00 /bin/tcsh -i
 10612 pts/8    S  0:00 /bin/ksh ./test.ksh
 10613 pts/8    S  0:00 sleep 100
 10615 pts/8    O  0:00 ps t pts/8
tools:~#192% kill -BUS 10612
tools:~#193%
[1]    Bus error              ./test.ksh

tools:~#193% ps 10613
   PID TT       S  TIME COMMAND
 10613 pts/8    S  0:00 sleep 100
tools:~#195% cat test.ksh
#!/bin/ksh
sleep 100

I'm running Solaris 2.6 if it matters.

Quote:>However - If I send a kill -11 (SEGV) signal to the script pid then
>the script dies but the child is left running.

>Anyone know what the reason is for this?

I don't think there's any reason for *either* of them to kill the child
process.  Child processes are not normally killed when their parent
terminates; instead they're adopted by init (pid 1).  The only reason they
might be killed is if the parent has a handler for the signal, and that
handler causes it to kill its children.

If you instead send the signal to the process *group* rather than just the
parent process, it should kill both of them.  You send to a process group
by specifying the target as a negative number:

tools:~#197% ./test.ksh &
[1] 10624
tools:~#198% ps t pts/8
   PID TT       S  TIME COMMAND
   487 pts/8    R  0:00 /bin/tcsh -i
 10624 pts/8    S  0:00 /bin/ksh ./test.ksh
 10625 pts/8    S  0:00 sleep 100
 10626 pts/8    O  0:00 ps t pts/8
tools:~#199% kill -BUS -10624
tools:~#200%
[1]    Bus error              ./test.ksh

tools:~#200% ps 10625
   PID TT       S  TIME COMMAND

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. killing a shell script is not killing child processes

dispatcher (NOHUP mode)->daemon->shell script (parent
PID)->executables(child PIDs)

When we try to kill shell script (parent PID) with kill-9 command, I
am expecting that all executables (child PIDs) that are running from
shell script should also be killed.

Shell script process is getting killed but not the child processes.

I tried read all the messages patiently but it added up more
confusions.

I found a way to kill all child processes before killing parent shell
script but trying to find a answer for this behaviour.

Any expert responses are welcome.

Cheers,
Srinivas

2. gzip/compress compression routine/library want

3. beta HOWTO for the Mgr window system

4. Bourne Shell script, that kills its child-processes?

5. rmt for WinNT

6. how to kill a child process that runs other children processes

7. XFree86-4.1.0.1 and Intel i815

8. How can kill all child processes without killing parent process ?

9. shell script does not pass on SIGTERM to child process

10. kill child and its all grad child processes?

11. Child processes left behind when killing script

12. help for script kill process child