def kill(self, sig=signal.SIGTERM):
while self.is_alive():<EOL><INDENT>self.killed = True<EOL>time.sleep(POLLING_DELAY) <EOL>if not self.spawned:<EOL><INDENT>continue <EOL><DEDENT>if self.process.poll() is None: <EOL><INDENT>self.process.send_signal(sig)<EOL>try: <EOL><INDENT>os.waitpid(self.process.pid, getattr(os, "<STR_LIT>", <NUM_LIT:1>))<EOL><DEDENT>except OSError: <EOL><INDENT>pass<EOL><DEDENT><DEDENT>break <EOL><DEDENT>self.join()<EOL>
Terminate the test job.

Kill the subprocess if it was spawned, abort the spawning
process otherwise. This information can be collected afterwards
by reading the self.killed and self.spawned flags.

Also join the 3 related threads to the caller thread. This can
be safely called from any thread.

This method behaves as self.join() when the thread isn't alive,
i.e., it doesn't raise an exception.

The ``sig`` parameter should be either:

* ``signal.SIGKILL`` (``9``), on Linux or OSX;
* ``signal.SIGTERM`` (``15``), the default value. On Windows
  this one calls the ``TerminateProcess`` Win32 API function.