3
# Copyright (C) 2008, 2012, 2013 Canonical Ltd.
4
# Author: Colin Watson <cjwatson@ubuntu.com>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; version 3 of the License.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
"""Run a process, killing it if it takes too long."""
20
from __future__ import print_function
22
from optparse import OptionParser
26
sys.path.insert(0, os.path.join(sys.path[0], os.pardir, "lib"))
30
from cdimage.osextras import run_bounded
32
parser = OptionParser("%prog number-of-seconds command [argument ...]")
33
_, args = parser.parse_args()
35
parser.error("need number of seconds")
37
parser.error("need command")
39
timeout = float(args[0])
41
parser.error("number of seconds is not numeric")
42
run_bounded(timeout, args[1:])
45
if __name__ == "__main__":