Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > popen3,4 and SIGTERM

Thread Tools

popen3,4 and SIGTERM

Zoran Bosnjak
Posts: n/a
This simple script works with python2.1.1, but it does not work with any
newer version of python on linux. Do you think it is a bug? Where?

This program does nothing, it just suppose to end after 3 seconds,
but os.kill(...) does not kill the ping process. Even if I do it from
the shell, I need to use kill -9 <pid>.

With python2.1.1 it works as expected.


---- cut here
import os, time, signal, threading, string
from popen2 import Popen3, Popen4

pid = 0

def run():
global pid
f = Popen4('ping localhost')
pid =
print 'pid from thread', pid
while 1:
s = f.fromchild.readline()
if not s: break

t = threading.Thread(target=run)
print 'timeout'
print 'pid from main', pid
os.kill(pid, signal.SIGTERM)
print 'bye'

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ruby bug with fork and signals (SIGTERM) Andreas Otto Ruby 2 10-12-2010 11:12 AM
Child process does not exit after receiving SIGTERM Teresa C Programming 2 04-06-2004 01:26 AM
RE: Repost: Can't sys.exit() from SIGTERM handler? Andrew Athan Python 0 01-06-2004 02:35 AM
Repost: Can't sys.exit() from SIGTERM handler? Andrew Athan Python 0 01-06-2004 01:27 AM
robust clean-up with SIGTERM (was Re: Again, how to write a cleanup function for a module in C ) Jane Austine Python 2 08-16-2003 04:01 AM