Add timeout script from https://github.com/pshved/timeout

This allows to properly limit time and memory of executed processes and
their subprocesses.
Improve handling of timeouts and memory limits using the timeout script.

This makes sure that all subprocesses are included in the handling of memory limits.