#!/bin/sh { ./time_consuming_binary -a param -a notherparam --pleaseblock } & CHILDPID=$! # Kill it after 30 sec sleep 30 kill -9 $CHILDPID 2>&1 /dev/nullHow to check if it had to be killed or not? Measure the wall time of the execution :) I've used it in a Nagios service check, the thing it watched either returned under 5 sec or blocked indefinitely (thanks, NFS), hence the 30 secs.
According to The Directive 2009/24/EC of the European Parliament and of the Council, and Sec.103(f) of the DMCA (17 U.S.C. § 1201 (f)), the reverse engineering act committed to creating these blog posts is considered legal, as this is an original attempt to improve interoperability, and cannot be waived by license agreements.
The views expressed on this blog are my own and do not necessarily reflect the views of my past and present employers.
2016-02-19
bash: homemade timeout replacement
So I was young and reckless, and didn't know there is a command called timeout in coreutils. This is how I managed to do it:
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment