Simple and interruptible timeout tool
Project description
Synopsys
The ptimeout utility is a python script implementing an interface similar to GNU timeout with the additional ability to terminate all processes launched from the timeout session.
In order to terminate all processes launched as part of the timeout session, an environment variable is propagated along with processes creation.
This heuristic enables terminations of detached processes even when they are not anymore in the process parent-child tree.
This also avoids the usage of process groups or process session leadership which have some undesirable effect observed with timeout tools provided with standard distributions. This approach is thus more transparent w.r.t. to overall process management.
The limitation to this approach is when some process reset its environment, in which case it will not be tracked anymore (nor any of its child) by the termination heuristic. In this case the sub-process tree may not terminate as part of the timeout session.
Download
Download the last stable version of the script from there: https://raw.githubusercontent.com/guillon/ptimeout/master/ptimeout
Examples
A typical usage of such a tool if for limiting the time of a batch job which may fall into non terminating condition such as in validation scripts or test processes.
Also one generally expect the whole set of executed processes as part of the job lifetime to be teminated when the job terminates, hence the termination heuristic.
Example of usage for limiting a batch script to 1 hour duration:
$ ptimeout 3600 script.sh
By default script.sh and all process executed from its process tree will be terminated with SIGTERM after 3600 seconds, or killed by SIGKILL 10 seconds after if still persistent.
If one wants only process garbage collection, use a timeout of 0 as in:
$ ptimeout 0 script.sh
In this case, the tool will not bound the execution time, but will still garbage collect all processes when receiving an interrupting signal.
The usage of ptimeout can be recursive and there is not side effect with respect to interactive/sessions/tty modes.
Get the command line help with:
$ ptimeout --help
usage: ptimeout [-h] [-v] [-d] [-s SIGNAL] [-k KILL_AFTER] [-c CATCH_SIGNALS]
[-l LIST] [-f FORMAT]
[duration] [command] ...
....
Build and Install
This script requires python 2.6, 2.7 or 3.3+.
The script can be used directly without installation.
A makefile is provided anyway for completion and testing purpose.
Build with:
$ make all # a no-op actually
Run unittests with:
$ make check
Install with, for instance:
$ make install PREFIX=$HOME/local # Default is PREFIX=/usr/local
References
Refer to the project home page at: http://guillon.github.com/ptimeout
Refer to the current build and validation status at: https://travis-ci.org/guillon/ptimeout?branches
Fill issues and enhancement request at: https://github.com/guillon/ptimeout/issues
License
The tool is distributed under the GPLv2 license.
Refer to the COPYING file: https://github.com/guillon/ptimeout/blob/master/COPYING Refer to the COPYRIGHT file: https://github.com/guillon/ptimeout/blob/master/COPYRIGHT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file ptimeout-1.4.0.tar.gz
.
File metadata
- Download URL: ptimeout-1.4.0.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a81d402e826ddcae758e79165ad6e7b568318c3052969f9b030d1375b137016 |
|
MD5 | e7c4a3874320d34d0882e50f7d4c4ce0 |
|
BLAKE2b-256 | ac5d69dd81836cd98b3fd2e769fdbe605398dac15de305fc93d8ed8b14dc1065 |
File details
Details for the file ptimeout-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: ptimeout-1.4.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 334b8aca1a667719584fb07787c242c3b64a4deda6e23bec52dd8c2a2ce0f9e1 |
|
MD5 | 3bcf769c19927c4681325ecaf86bf1af |
|
BLAKE2b-256 | 2bd6adcc08e1861544ba77313fbec33d2dc6d94b6078c5774382bdad943eac5a |
File details
Details for the file ptimeout-1.4.0-py2-none-any.whl
.
File metadata
- Download URL: ptimeout-1.4.0-py2-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70e442523517039ab2f06809d66615e21b0cb2bddb28a7eb81425f67ca5e72c4 |
|
MD5 | 8768aeccaa6d64ae93adababf055dbb1 |
|
BLAKE2b-256 | d319bb997673a2eecbd56904ffb97da51a8e41d68428d7f4e49ba3dda9bc6071 |