Index: Lib/subprocess.py =================================================================== --- Lib/subprocess.py 2009-09-29 21:18:11.000000000 +0200 +++ Lib/subprocess.py 2009-10-15 16:40:11.000000000 +0200 @@ -934,7 +934,10 @@ def terminate(self): """Terminates the process """ - TerminateProcess(self._handle, 1) + if self.poll() is None: + TerminateProcess(self._handle, 1) + else: + raise OSError("Child %d has already terminated." %self.pid) kill = terminate @@ -1232,11 +1235,14 @@ self.wait() return (stdout, stderr) - + def send_signal(self, sig): """Send a signal to the process """ - os.kill(self.pid, sig) + if self.poll() is None: + os.kill(self.pid, sig) + else: + raise OSError("Child %d has already terminated." %self.pid) def terminate(self): """Terminate the process with SIGTERM