From owner-freebsd-questions@freebsd.org Tue Jan 23 10:23:20 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D6215EC91EC for ; Tue, 23 Jan 2018 10:23:20 +0000 (UTC) (envelope-from 4250.10.freebsd-questions=freebsd.org@email-od.com) Received: from bca5.email-od.com (bca5.email-od.com [207.246.239.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8CFAE73327 for ; Tue, 23 Jan 2018 10:23:19 +0000 (UTC) (envelope-from 4250.10.freebsd-questions=freebsd.org@email-od.com) DKIM-Signature: v=1; a=rsa-sha256; d=email-od.com;i=@email-od.com;s=dkim; c=relaxed/relaxed; q=dns/txt; t=1516703001; x=1519295001; h=x-thread-info:date:from:to:subject:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; bh=5fvBzY+G74Wh1mpdOktGQJWJczYQiy0gOrpVARy6270=; b=vNnJKpwv3U88nMtCPrGf5VvfodZMC7ei6Dbm+2Zzo6PqYexKznyKsDPltXi1fRCNAyUGv4PlEId3PYYKz8QcRD/tupPIlmVA4NqzYZGex2qC2V1CqTtPZPzHNv224kshti2/8DB8eY9Xo8SurBdbWgQkKkx+ghaus2en4Z192RU= X-Thread-Info: NDI1MC4xMi44YTAwMDAwMDFlNzIzMC5mcmVlYnNkLXF1ZXN0aW9ucz1mcmVlYnNkLm9yZw== Received: from r1.us-west-2a.aws.in.socketlabs.com (r1.us-west-2a.aws.in.socketlabs.com [54.186.235.111]) by bca2.email-od.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Tue, 23 Jan 2018 05:23:03 -0500 Received: from smtp.lan.sohara.org (EMTPY [89.127.62.20]) by r1.us-west-2a.aws.in.socketlabs.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Tue, 23 Jan 2018 05:23:02 -0500 Received: from [192.168.63.1] (helo=steve.lan.sohara.org) by smtp.lan.sohara.org with smtp (Exim 4.90 (FreeBSD)) (envelope-from ) id 1edvjG-0005vG-6G for freebsd-questions@freebsd.org; Tue, 23 Jan 2018 10:22:58 +0000 Date: Tue, 23 Jan 2018 10:22:58 +0000 From: Steve O'Hara-Smith To: freebsd-questions@freebsd.org Subject: Re: Limit resources for a given program Message-Id: <20180123102258.32e9f4a61132c86b25cbfede@sohara.org> In-Reply-To: References: X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; amd64-portbld-freebsd11.0) X-Clacks-Overhead: "GNU Terry Pratchett" Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jan 2018 10:23:21 -0000 On Tue, 23 Jan 2018 12:40:17 +0700 Olivier wrote: > Hi, > > Is there a way, in FreeBSD, to limit the clocktime for a given command? > > I use LibreOffice to automatically convert many types of documents to > PDF. When it is an HTML document with external links, it will run > indefinitely, trying to access the external resources. It will not use > much CPU but mostly sits idled, so limits(8) -t is not the solution, nor > is rctl(8) that needs a process ID (but I only have the command name) or > a user ID (but I don't want to limit a user, just that program). > > Any idea how I can solve that? Something like this (untested) should do the trick: #!/bin/sh libreoffice "$@" & rctl -a process:$$:wallclock:sigterm=3600 -- Steve O'Hara-Smith