[PATCH] D14706: [lit] Implement support of per test timeout in lit.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 8 02:46:17 PST 2015


On 6 December 2015 at 10:51, Dan Liew <dan at su-root.co.uk> wrote:
> delcypher added a comment.
>
> In http://reviews.llvm.org/D14706#303390, @cmatthews wrote:
>
>> I think needing a package that is not included in the Python standard release this is a serious issue. lit has no dependencies. That makes it easy to build and test anywhere.
>
>

So I was having a read around on stackoverflow to see how killing a
process and its children in Windows and came across this.

http://stackoverflow.com/questions/1230669/subprocess-deleting-child-processes-in-windows

Looks like Windows has special support for doing this using "job objects".

@JF Bastien: I noticed you commented on this so clearly you have some
experience here.

For context I've implement a patch that adds support for a per test
timeout in lit but my current implementation relies an external python
module (pustil) to iterate through a process's children and kill them.
This dependency is a soft dependency because the import of the module
only occurs if a timeout is requested.

Adding this soft dependency seems to be controversial so I was taking
a look at how this might be implemented without using psutil. So far
it seems that

* For POSIX operating systems we can call ``os.setsid()`` before the
fork and use ``os.killpg()`` to kill all the processes
* For Windows it looks like we can use these "job objects"
* Not sure if there are any other platforms lit needs to support

Using the above seems considerably more complicated than my current
solution. Currently all processes are created using
``subprocess.Popen()`` and killed sing
``lit.util.killProcessAndChildren()``. If I try doing the above I then
have the problem that killing a process requires knowing how it was
created which is going to make the implementation messier. Perhaps
some sort of wrapper class is needed here to hide the differences.

Given that you clearly have experience with these "job objects" on
Windows I was wondering if you had any opinions here.

Thanks,
Dan.


More information about the llvm-commits mailing list