Killing processes without using 'kill' 
Author Message
 Killing processes without using 'kill'

I have a problem to kill a process that has been started with
the Tcl command 'open'. Say that it exists an executable called 'xxx'
then I would like to do the following:
:
set f [open |xxx]
set childPid [pid $f]
:
:
# Here I want to kill the process pointed to by $childPid
# it can be done with 'exec kill $childPid' but I don't want
# to do it like that since I have the feeling that it is not very
# portable to Mac, WIN95, NT ... (I'm running on UNIX and I don't know
# how these things are done on Mac/WIN95/NT)

Anyone have a suggestion???

regards,

--
Mats Pettersson    

Ascom Hasler Ltd    
Belpstrasse 37      
CH-3000 Berne 14
SWITZERLAND

Tel: +41 31 999 1290    Fax: +41 31 999 3735
http://www.*-*-*.com/



Tue, 27 Jul 1999 03:00:00 GMT  
 Killing processes without using 'kill'

: I have a problem to kill a process that has been started with
: the Tcl command 'open'. Say that it exists an executable called 'xxx'
: then I would like to do the following:
: :
: set f [open |xxx]
: set childPid [pid $f]
: :
: :
: # Here I want to kill the process pointed to by $childPid
: # it can be done with 'exec kill $childPid' but I don't want
: # to do it like that since I have the feeling that it is not very
: # portable to Mac, WIN95, NT ... (I'm running on UNIX and I don't know
: # how these things are done on Mac/WIN95/NT)

How about "close $f"? It works under Unix, and maybe under Win32, too.

mike



Sat, 31 Jul 1999 03:00:00 GMT  
 Killing processes without using 'kill'

But close does not kill the process, it will wait till
it dies by itself!
/MP

Quote:


> : I have a problem to kill a process that has been started with
> : the Tcl command 'open'. Say that it exists an executable called 'xxx'
> : then I would like to do the following:
> : :
> : set f [open |xxx]
> : set childPid [pid $f]
> : :
> : :
> : # Here I want to kill the process pointed to by $childPid
> : # it can be done with 'exec kill $childPid' but I don't want
> : # to do it like that since I have the feeling that it is not very
> : # portable to Mac, WIN95, NT ... (I'm running on UNIX and I don't know
> : # how these things are done on Mac/WIN95/NT)

> How about "close $f"? It works under Unix, and maybe under Win32, too.

> mike

--
Mats Pettersson    

Ascom Hasler Ltd    
Belpstrasse 37      
CH-3000 Berne 14
SWITZERLAND

Tel: +41 31 999 1290    Fax: +41 31 999 3735
http://www.ascom.ch



Sat, 31 Jul 1999 03:00:00 GMT  
 Killing processes without using 'kill'

: But close does not kill the process, it will wait till
: it dies by itself!

Huh?

% set desc [open |gdb RDWR]
file5
% gets $desc
GDB is free software and you are welcome to distribute copies of it
% exec ps t
  PID TTY STAT  TIME COMMAND
17246  p4 S    0:18 -bash
20565  p4 S    0:00 sh /home/mike/bin/mytcl
20566  p4 S    0:00 /home/mike/tcldev/shlibs/tclsh
20588  p4 S    0:00 gdb
20592  p4 R    0:00 ps t
% close $desc
% exec ps t
  PID TTY STAT  TIME COMMAND
17246  p4 S    0:18 -bash
20565  p4 S    0:00 sh /home/mike/bin/mytcl
20566  p4 S    0:00 /home/mike/tcldev/shlibs/tclsh
20596  p4 R    0:00 ps t
% exit

So, closing the pipe killed gdb w/out{*filter*} tclsh (note that I didn't
pass the "quit" command to gdb). I didn't check this for win32, though.

mike



Sat, 31 Jul 1999 03:00:00 GMT  
 Killing processes without using 'kill'


: : But close does not kill the process, it will wait till
: : it dies by itself!

: Huh?

: So, closing the pipe killed gdb w/out{*filter*} tclsh (note that I didn't
: pass the "quit" command to gdb). I didn't check this for win32, though.

I think it really depends on whether that process is reading its
stdin. If not, it may run forever after you close the file (and only
get killed when tclsh dies).

Ioi



Tue, 03 Aug 1999 03:00:00 GMT  
 Killing processes without using 'kill'

Quote:


> : But close does not kill the process, it will wait till
> : it dies by itself!

> Huh?

The process is unlikely to die until is discovers that it can't
write to its standard output, so

        % set fd [open "|sleep 300"]
        % exec ps -p[pid $fd]
           PID TTY       TIME COMMAND
          6596 pts/3     0:00 sleep
        % close $fd
        <long pause for nearly five minutes>

Of course, if sleep tried to write to stdout, the story would be
different:

        % set fd [open "|yes"]
        % exec ps -p[pid $fd]
           PID TTY       TIME COMMAND
          6608 pts/3     0:00 yes
        % close $fd
        <instant response>
        child killed: write on pipe with no readers

--
John Haxby

------------------------------------------------------------------------
These are my opinions, not my employer's.



Sun, 08 Aug 1999 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. kill '-SIGHUP', pgid -vs- kill 'SIGHUP', 0

2. Thread#kill doesn't kill processes inside a thread

3. Please help- Killing Python 'processes'

4. kill a subprocess without killing itself

5. vwait doesn't kill background processes on NT (only)

6. Killing a thread from a 'controller'

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

8. Kill the kill file for now

9. Child process on crashing kills it parent process

10. PLEASE DON'T KILL THE LIST

11. Vispro Rexx can't kill a rxftp thread

12. fixpak#10 kills visual rexx'es

 

 
Powered by phpBB® Forum Software