Index: Lib/subprocess.py =================================================================== --- Lib/subprocess.py 2009-10-15 23:52:53.000000000 +0200 +++ Lib/subprocess.py 2009-10-15 23:55:54.000000000 +0200 @@ -982,7 +982,10 @@ def terminate(self): """Terminates the process """ - TerminateProcess(self._handle, 1) + if self.poll() is None: # child process is still running + TerminateProcess(self._handle, 1) + else: + raise OSError("Child %d has already been terminated." % self.pid) kill = terminate @@ -1355,7 +1358,10 @@ def send_signal(self, sig): """Send a signal to the process """ - os.kill(self.pid, sig) + if self.poll() is None: # child process is still running + os.kill(self.pid, sig) + else: + raise OSError("Child %d has already been terminated." % self.pid) def terminate(self): """Terminate the process with SIGTERM