From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 11 14:01:59 2021 Received: (at submit) by debbugs.gnu.org; 11 Oct 2021 18:01:59 +0000 Received: from localhost ([127.0.0.1]:60864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZzcc-00049M-VT for submit@debbugs.gnu.org; Mon, 11 Oct 2021 14:01:59 -0400 Received: from lists.gnu.org ([209.51.188.17]:46226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mZzcb-00049F-Gp for submit@debbugs.gnu.org; Mon, 11 Oct 2021 14:01:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZzcZ-0007vC-Mm for bug-coreutils@gnu.org; Mon, 11 Oct 2021 14:01:56 -0400 Received: from insect.birch.relay.mailchannels.net ([23.83.209.93]:19086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZzcX-00043U-HU for bug-coreutils@gnu.org; Mon, 11 Oct 2021 14:01:55 -0400 X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 55C32601BC0 for ; Mon, 11 Oct 2021 18:01:45 +0000 (UTC) Received: from mailgw-01.dd24.net (unknown [127.0.0.6]) (Authenticated sender: instrampxe0y3a) by relay.mailchannels.net (Postfix) with ESMTPA id 9CCDB60087C for ; Mon, 11 Oct 2021 18:01:44 +0000 (UTC) X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from mailgw-01.dd24.net (mailgw-01.dd24.net [193.46.215.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.112.147.114 (trex/6.4.3); Mon, 11 Oct 2021 18:01:45 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: instrampxe0y3a|x-authsender|calestyo@scientia.net X-MailChannels-Auth-Id: instrampxe0y3a X-Interest-Chemical: 7ba5badc5ae96c08_1633975305030_2781731339 X-MC-Loop-Signature: 1633975305029:1004370697 X-MC-Ingress-Time: 1633975305029 Received: from heisenberg.fritz.box (ppp-188-174-65-9.dynamic.mnet-online.de [188.174.65.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: calestyo@scientia.net) by smtp.dd24.net (Postfix) with ESMTPSA id 995AC5FC32 for ; Mon, 11 Oct 2021 18:01:42 +0000 (UTC) Message-ID: Subject: timeout: --foreground causes exit status 124, even if KILL was used From: Christoph Anton Mitterer To: bug-coreutils@gnu.org Date: Mon, 11 Oct 2021 20:01:42 +0200 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.0-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Received-SPF: none client-ip=23.83.209.93; envelope-from=calestyo@scientia.net; helo=insect.birch.relay.mailchannels.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hey. This time I've also checked the 9.0 documentation (hopefully I wasn't just too blind). I noticed that whenever --foreround is used, timeout exits with a 124 status (instead of the documented 128+9) regardless of whether the KILL is sent because of --signal=KILL or --kill-after=n . Thanks, Chris. btw: I'm sill on Debian sid's 8.32 version of coreutils. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 11 17:04:31 2021 Received: (at 51135-done) by debbugs.gnu.org; 11 Oct 2021 21:04:31 +0000 Received: from localhost ([127.0.0.1]:32813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2TH-0006go-4o for submit@debbugs.gnu.org; Mon, 11 Oct 2021 17:04:31 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:42638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2TF-0006gZ-65 for 51135-done@debbugs.gnu.org; Mon, 11 Oct 2021 17:04:29 -0400 Received: by mail-wr1-f41.google.com with SMTP id v17so60063758wrv.9 for <51135-done@debbugs.gnu.org>; Mon, 11 Oct 2021 14:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5RDulSXWTkmUjYL0AbRylR6eMUdjFHfXoA/Jmlv1kMs=; b=OGCyncYTDrfTNC9u7xIG5Uk8eghpRLoMa4AH0nwvIxn2QQFa9LQ9yN+ld16/wuyHBV o1gnpgKEQsBB7/PNs8calGmgL2cStqFYDqJhVmmyR7IX21KfzjJXa/9X7qqYt5HdqeVO bNpNmgaz2d1llo68PmlD42rDkRBJ8b/DWklcDplWwONKUepk+y0mlyOY2KBEQG5R+Xan r2mAmN/6nqp86p2MtS1Vi1Zao90BeqeE6Zy6dpz0ElVnDFmIXwztqYCZElCrrTEzLpVi RoEJ098h6vcKTubml/ACalrnh7x4B89qYGSKc+HGO1YeNg5luQEKXc2+ArE1ByJPGLNT VF6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5RDulSXWTkmUjYL0AbRylR6eMUdjFHfXoA/Jmlv1kMs=; b=cQS6+KM2qvN9ISI3ya2qKy9aV8nrgqHwneZUTHeOjn0K6g67EZOHk1Y1Uz294MF9de 8PaRotnr14mHDS0VfkKPMNuV4TbTo4RPX49Ulc7tHciu7Pcs7+ZdGEwHy7Yc8jlP7i17 gxRmp9peq8ju50SPXBbY4R0bu8R0jEVQXycmpGPIbRSFvph6miBzbTAHEFA6VtLFRkNF dfLnpXcGrQRB2515dtQ6LEvBhBKBvX3KnaPv04V+7+wVMzaqeV9/4LtFtVIBvaq4TBAW jt5KCkdmEsVY5IlttTXU2+8r7dq5Akq8Y9Gm/uI7G58x7PPGzz20tvqvH0DZdYEh+02h IKQg== X-Gm-Message-State: AOAM530AGVKPKp7nJWOmljK1/iY9uaxr9f2wHal9wslFrOMcf8X9lsGd PN2FnA7MZCgZySp64krK1gaQUzXdiC2U0g== X-Google-Smtp-Source: ABdhPJziDSLTW0CTKZZA/bbTKRxImiRTABj5nnXWHBOCJPFTcOgWckei8N3dH3ixX0UxXfoCXzO10Q== X-Received: by 2002:adf:ab17:: with SMTP id q23mr27206992wrc.78.1633986263112; Mon, 11 Oct 2021 14:04:23 -0700 (PDT) Received: from localhost.localdomain (86-40-129-104-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.40.129.104]) by smtp.googlemail.com with UTF8SMTPSA id q18sm580946wmc.7.2021.10.11.14.04.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Oct 2021 14:04:22 -0700 (PDT) Subject: Re: bug#51135: timeout: --foreground causes exit status 124, even if KILL was used To: Christoph Anton Mitterer , 51135-done@debbugs.gnu.org References: From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Mon, 11 Oct 2021 22:04:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 51135-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 11/10/2021 19:01, Christoph Anton Mitterer wrote: > Hey. > > > This time I've also checked the 9.0 documentation (hopefully I wasn't > just too blind). > > > I noticed that whenever --foreground is used, timeout exits with a 124 > status (instead of the documented 128+9) regardless of whether the KILL > is sent because of --signal=KILL or --kill-after=n . Yes --foreground gives timeout(1) more control over the exit status in this case. I'll add some clarification to the texinfo manual along these lines: -In case of the @samp{KILL(9)} signal, @command{timeout} returns with +In the case of the @samp{KILL(9)} signal, @command{timeout} returns with exit status 137, regardless of whether that signal is sent to @var{command} or to @command{timeout} itself, i.e., these cases cannot be distinguished. In the latter case, the @var{command} process may still be alive after @command{timeout} has forcefully been terminated. +However if the @option{--foreground} option is specified then +@command{timeout} will not send any signals to its own process, +and so it will exit with one of the other exit status values detailed above. thanks, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 11 17:11:43 2021 Received: (at 51135) by debbugs.gnu.org; 11 Oct 2021 21:11:43 +0000 Received: from localhost ([127.0.0.1]:32820 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2aE-0006rU-U8 for submit@debbugs.gnu.org; Mon, 11 Oct 2021 17:11:43 -0400 Received: from purple.birch.relay.mailchannels.net ([23.83.209.150]:65480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2aD-0006rM-Bv for 51135@debbugs.gnu.org; Mon, 11 Oct 2021 17:11:42 -0400 X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 9956A7618AF; Mon, 11 Oct 2021 21:11:39 +0000 (UTC) Received: from mailgw-01.dd24.net (unknown [127.0.0.6]) (Authenticated sender: instrampxe0y3a) by relay.mailchannels.net (Postfix) with ESMTPA id 938307618B5; Mon, 11 Oct 2021 21:11:38 +0000 (UTC) X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from mailgw-01.dd24.net (mailgw-01.dd24.net [193.46.215.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.99.42.170 (trex/6.4.3); Mon, 11 Oct 2021 21:11:39 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: instrampxe0y3a|x-authsender|calestyo@scientia.net X-MailChannels-Auth-Id: instrampxe0y3a X-Bottle-Spicy: 04bd4f824159b814_1633986699310_20641043 X-MC-Loop-Signature: 1633986699310:2621111415 X-MC-Ingress-Time: 1633986699310 Received: from heisenberg.fritz.box (ppp-188-174-65-9.dynamic.mnet-online.de [188.174.65.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: calestyo@scientia.net) by smtp.dd24.net (Postfix) with ESMTPSA id 42F295FC32; Mon, 11 Oct 2021 21:11:36 +0000 (UTC) Message-ID: Subject: Re: bug#51135: timeout: --foreground causes exit status 124, even if KILL was used From: Christoph Anton Mitterer To: =?ISO-8859-1?Q?P=E1draig?= Brady , 51135@debbugs.gnu.org Date: Mon, 11 Oct 2021 23:11:35 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.0-2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 51135 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, 2021-10-11 at 22:04 +0100, Pádraig Brady wrote: > +However if the @option{--foreground} option is specified then > +@command{timeout} will not send any signals to its own process, > +and so it will exit with one of the other exit status values > detailed above. So 137 is only used when the signal was sent to timeout itself? I'd have actually found it quite nice if 137 was used *even* with --foreground. That way one could differentiate between whether COMMAND had the chance to do cleanups, or whether the calling process should take care on that. For example, I use timeout with a program that reads a phassphrase and prints it to stdout. It disables the terminal's ECHO, so when it has to be killed, the calling process would need to re-enable that mnually. Cheers, Chris. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 11 17:20:43 2021 Received: (at 51135) by debbugs.gnu.org; 11 Oct 2021 21:20:43 +0000 Received: from localhost ([127.0.0.1]:32849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2ix-000780-JW for submit@debbugs.gnu.org; Mon, 11 Oct 2021 17:20:43 -0400 Received: from mail-wr1-f45.google.com ([209.85.221.45]:43865) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2iv-00077l-Vw for 51135@debbugs.gnu.org; Mon, 11 Oct 2021 17:20:42 -0400 Received: by mail-wr1-f45.google.com with SMTP id r7so60253981wrc.10 for <51135@debbugs.gnu.org>; Mon, 11 Oct 2021 14:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=q/iqTSHpEWJRAE2S5wcEUlnziW/nMc+HsMsRbDuSpOA=; b=FLCIYXIe+deQBHU7U8zWBOj04N3tUdbyG0pDakgeMSJvGts49YTh1uN6gmrog30NIZ Vgq7BVnltAWd7pPK031NlAyfHzU5eB0cjheAPb6ZENweXeh+WQiDZNz/wKwn5UVRTJQc DbfwVoBSTgI0ew4wEjvX9QCLssJRW49/pGMHp78QT3YVGiYTEScGJJH66AE/Mp9JE5ye 1wnDu1BbUHTUsRq7CJRRe0YfbtzPJoE19y755ECj4TGDK/3atCH+rZgxPiPLvv3Pk76n jR7/asmx6TN5VOrAPKxJHzGc8lol1Ok3cPbneHXwj8AIRAzxHj8VxNmj8CLmTlyIXGME aE5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=q/iqTSHpEWJRAE2S5wcEUlnziW/nMc+HsMsRbDuSpOA=; b=nR/4lm8B6goBPBQ/uWILcwksiPh1pofJmHV7L1CSk/225UBW5kmkxW68LpT4ORwJod AIrjnpID0EHnj+sJJa8yDjR9EhvO2dEh0ZpPeIqw+PXhMZGJfJBteazCHRvm6NJm97nV 23TemHX1QHP6FcSrh5IySze+rYXQZZKD6OXu9/T0mVY3Pno/zYYZr6hoFMu2mKzYYTSN 2Vtq1t4BJBgGOxQb+gcINEuzBw+RQEcUwZOuSQvvyLtDR/sKAAOc/079/zRorT4X+eVP Bi72AZNc7yVs86LrKIujzv0FdSJ1i79DzgpAWSUxESU+fJUML/XRSb0p+/VBP+b+ORId 3awg== X-Gm-Message-State: AOAM5330g9bwTpKmYfy32udt45M7VFC7NgBEzawGAPElKf8jQH4Glx47 HWyqe1UP/Ej87WFY0kQ3a0g8uW0L7jWp1w== X-Google-Smtp-Source: ABdhPJztyn1zZ4tKbN/hzhI1Bx0RS/IA+Wnd374y49hDcQvnR9+a2wBb7bvCMHIGw82omIKfc/y7Tg== X-Received: by 2002:a1c:4c19:: with SMTP id z25mr1570992wmf.0.1633987235803; Mon, 11 Oct 2021 14:20:35 -0700 (PDT) Received: from localhost.localdomain (86-40-129-104-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.40.129.104]) by smtp.googlemail.com with UTF8SMTPSA id l18sm593176wmh.39.2021.10.11.14.20.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Oct 2021 14:20:35 -0700 (PDT) Subject: Re: bug#51135: timeout: --foreground causes exit status 124, even if KILL was used To: Christoph Anton Mitterer , 51135@debbugs.gnu.org References: From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Mon, 11 Oct 2021 22:20:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 51135 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 11/10/2021 22:11, Christoph Anton Mitterer wrote: > On Mon, 2021-10-11 at 22:04 +0100, Pádraig Brady wrote: >> +However if the @option{--foreground} option is specified then >> +@command{timeout} will not send any signals to its own process, >> +and so it will exit with one of the other exit status values >> detailed above. > > So 137 is only used when the signal was sent to timeout itself? > > I'd have actually found it quite nice if 137 was used *even* with > --foreground. > > That way one could differentiate between whether COMMAND had the chance > to do cleanups, or whether the calling process should take care on > that. > > > For example, I use timeout with a program that reads a phassphrase and > prints it to stdout. > It disables the terminal's ECHO, so when it has to be killed, the > calling process would need to re-enable that mnually. For that use case it's probably best to use --preserve-status, in which case the 137 from the child getting the SIGKILL will be propagated through. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 11 17:24:22 2021 Received: (at 51135) by debbugs.gnu.org; 11 Oct 2021 21:24:22 +0000 Received: from localhost ([127.0.0.1]:32853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2mU-0007Dl-2V for submit@debbugs.gnu.org; Mon, 11 Oct 2021 17:24:22 -0400 Received: from bee.dogwood.relay.mailchannels.net ([23.83.211.14]:4079) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma2mS-0007Db-E6 for 51135@debbugs.gnu.org; Mon, 11 Oct 2021 17:24:21 -0400 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6AB4954249A; Mon, 11 Oct 2021 21:24:16 +0000 (UTC) Received: from mailgw-01.dd24.net (100-96-18-141.trex.outbound.svc.cluster.local [100.96.18.141]) (Authenticated sender: instrampxe0y3a) by relay.mailchannels.net (Postfix) with ESMTPA id A57E05412E2; Mon, 11 Oct 2021 21:24:00 +0000 (UTC) Received: from mailgw-01.dd24.net (mailgw-01.dd24.net [193.46.215.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.141 (trex/6.4.3); Mon, 11 Oct 2021 21:24:16 +0000 Received: from heisenberg.fritz.box (ppp-188-174-65-9.dynamic.mnet-online.de [188.174.65.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: calestyo@scientia.net) by smtp.dd24.net (Postfix) with ESMTPSA id C09E45FCA6; Mon, 11 Oct 2021 21:23:57 +0000 (UTC) Message-ID: Subject: Re: bug#51135: timeout: --foreground causes exit status 124, even if KILL was used From: Christoph Anton Mitterer To: =?ISO-8859-1?Q?P=E1draig?= Brady , 51135@debbugs.gnu.org Date: Mon, 11 Oct 2021 23:23:57 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.0-2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 51135 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, 2021-10-11 at 22:20 +0100, Pádraig Brady wrote: > For that use case it's probably best to use --preserve-status, > in which case the 137 from the child getting the SIGKILL > will be propagated through. But wouldn't that make me loose the 124, if COMMAND could actually be SIGTERMed? From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 11 21:55:12 2021 Received: (at 51135) by debbugs.gnu.org; 12 Oct 2021 01:55:12 +0000 Received: from localhost ([127.0.0.1]:33066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma70a-0001R6-KW for submit@debbugs.gnu.org; Mon, 11 Oct 2021 21:55:12 -0400 Received: from fossa.birch.relay.mailchannels.net ([23.83.209.62]:37528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma70X-0001Qt-Rg for 51135@debbugs.gnu.org; Mon, 11 Oct 2021 21:55:10 -0400 X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 803AA229F8; Tue, 12 Oct 2021 01:55:08 +0000 (UTC) Received: from mailgw-02.dd24.net (100-96-18-141.trex.outbound.svc.cluster.local [100.96.18.141]) (Authenticated sender: instrampxe0y3a) by relay.mailchannels.net (Postfix) with ESMTPA id 5E45522A49; Tue, 12 Oct 2021 01:55:07 +0000 (UTC) X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from mailgw-02.dd24.net (mailgw-02.dd24.net [193.46.215.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.141 (trex/6.4.3); Tue, 12 Oct 2021 01:55:08 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: instrampxe0y3a|x-authsender|calestyo@scientia.net X-MailChannels-Auth-Id: instrampxe0y3a X-Slimy-Belong: 2e41a8887b132072_1634003708140_1032642214 X-MC-Loop-Signature: 1634003708140:822246022 X-MC-Ingress-Time: 1634003708140 Received: from heisenberg.fritz.box (ppp-188-174-65-9.dynamic.mnet-online.de [188.174.65.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: calestyo@scientia.net) by smtp.dd24.net (Postfix) with ESMTPSA id B480A5FC25; Tue, 12 Oct 2021 01:55:04 +0000 (UTC) Message-ID: Subject: Re: bug#51135: timeout: --foreground causes exit status 124, even if KILL was used From: Christoph Anton Mitterer To: =?ISO-8859-1?Q?P=E1draig?= Brady , 51135@debbugs.gnu.org Date: Tue, 12 Oct 2021 03:55:03 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.0-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 51135 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Thinking again about this: Don't you think one looses quite something if, with --foreground, one cannot differ (via the exit status) between a timeout that allowed the program to clean up and one (when KILLing) that didn't? Even if the KILL happens via killing timeout itself, couldn't it just return 128+9 in the case --foreground was enabled and the original signal had already been sent? Or is that technically not possible then? From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 12 09:50:50 2021 Received: (at 51135) by debbugs.gnu.org; 12 Oct 2021 13:50:50 +0000 Received: from localhost ([127.0.0.1]:40117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maIB7-0007fG-QP for submit@debbugs.gnu.org; Tue, 12 Oct 2021 09:50:50 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:45575) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maIB5-0007f0-0Z for 51135@debbugs.gnu.org; Tue, 12 Oct 2021 09:50:48 -0400 Received: by mail-wr1-f47.google.com with SMTP id r10so67246524wra.12 for <51135@debbugs.gnu.org>; Tue, 12 Oct 2021 06:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=Xl7bgqwZZFixc4aEaHBhIqxg3YYSthWF6fgnn9SGVOI=; b=YDo+BHlvfcSgUiQQyCiJfeQvUJYB8xY0/pL4siAE8H/aw7JydbkzlkI2hkY/wtmSgR +eWRvUQwYqk6r8bZKmDiiEazVvGmHWvMlkGEBeBfwMyTXWWV4j4uQt5ET7EVzmV6sWKl L9sNUWIy97mgBpFtJ4HfXvPFeo040iKM99skimhmVYfap0NmqU4cvXtEKECjy/DP7Vbq 0WjqnQRDgpyN0Y/1mYjh+PYS/5PFxQiYWXZwEHDDC+53/vC7kd1LQ2Hd03kXQxm/OgfV Hp3yDsRzQNXNxSHVtlsd5pPvOwTBR8oft46Q3T/RgS+F9Eqqq6nMjbeXfGwzh4O0l2ck FKHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=Xl7bgqwZZFixc4aEaHBhIqxg3YYSthWF6fgnn9SGVOI=; b=hh+DIJqTSrytWGoncPnxdqqeUim08vf3ZYCjph24gGDSiLQrzUzEwNPK8peFc+0wfI yzyAJUnJgAFLvxv5YQdQAVXVILdEJ8hotudB5TCWo2IAqOwtQxAjh+GHAeWvvyjFrwGa Z8NXHEZvm+V6+pGguLediQUC0W0wXZ9DCDnb1+SSs5X9x6xukBUIxhbwnL05/iCAWdwh zKGk8tfmAyQyhmy/Dut6Sye+f5pIikQAwhNKFYBys0cvjoEg/YsZVZziargELkLlGpOO RrVXEcYEQAWXF5NmYfWj+M6YI0KsMxNH+q0lv8MbOOwKxriTfqPpJofrpqHUtcmJgacr vO/w== X-Gm-Message-State: AOAM5310M4c0X7uiG2GDNqwHwRjeYX9jUcuzcDqXqnGZEfCsG3/WpzvH E4jHs/LsHwD7gsGoa7s86oNaL4gm8Pz7tw== X-Google-Smtp-Source: ABdhPJykt7lpl1WhcBTYH1pzywdk5HHLvzJlWHiBKZ3FRVXW3IcWZh+kQ967IpL090Pq49+pYobb9A== X-Received: by 2002:a05:600c:19cf:: with SMTP id u15mr5715127wmq.45.1634046640729; Tue, 12 Oct 2021 06:50:40 -0700 (PDT) Received: from localhost.localdomain (86-40-129-104-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.40.129.104]) by smtp.googlemail.com with UTF8SMTPSA id g1sm3378738wmk.2.2021.10.12.06.50.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Oct 2021 06:50:39 -0700 (PDT) Subject: Re: bug#51135: timeout: --foreground causes exit status 124, even if KILL was used To: Christoph Anton Mitterer , 51135@debbugs.gnu.org References: From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <8989a562-0ecb-e65a-3797-cfe90f9097e5@draigBrady.com> Date: Tue, 12 Oct 2021 14:50:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------AE6F94E2B25B5870F7DD38B0" Content-Language: en-US X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 51135 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) This is a multi-part message in MIME format. --------------AE6F94E2B25B5870F7DD38B0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/10/2021 02:55, Christoph Anton Mitterer wrote: > Thinking again about this: > > Don't you think one looses quite something if, with --foreground, one > cannot differ (via the exit status) between a timeout that allowed the > program to clean up and one (when KILLing) that didn't? > > > Even if the KILL happens via killing timeout itself, couldn't it just > return 128+9 in the case --foreground was enabled and the original > signal had already been sent? > Or is that technically not possible then? That is a fair point. If one is using --kill-after you have to check for both 124 and 137 anyway to see if it timed out. It is useful to know whether the command was forcably killed. Using --foreground to avoid the 137 exit status upon --kill-after is not until now documented, so we should probably adjust the exit status to be always 137 if a SIGKILL is sent. With the attached we now behave like: $ timeout -v -s0 --foreground -k2 1 sleep 3; echo $? timeout: sending signal EXIT to command ‘sleep’ timeout: sending signal KILL to command ‘sleep’ 137 $ timeout -v -s0 -k2 1 sleep 3; echo $? timeout: sending signal EXIT to command ‘sleep’ timeout: sending signal KILL to command ‘sleep’ Killed 137 cheers, Pádraig --------------AE6F94E2B25B5870F7DD38B0 Content-Type: text/x-patch; charset=UTF-8; name="timeout--foreground-k-status.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="timeout--foreground-k-status.patch" >From 0750fcdf3447366b074cb47dd8cbe88c83ed984d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Tue, 12 Oct 2021 14:32:57 +0100 Subject: [PATCH] timeout: ensure --foreground -k exits with status 137 * src/timeout.c (main): Propagate the killed status from the child. * doc/coreutils.texi (timeout invocation): Remove the description of the --foreground specific handling of SIGKILL, now that it's consistent with the default mode of operation. * tests/misc/timeout.sh: Add a test case. * NEWS: Mention the change in behavior. Fixes https://bugs.gnu.org/51135 --- NEWS | 7 +++++++ doc/coreutils.texi | 3 --- src/timeout.c | 5 +++++ tests/misc/timeout.sh | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 1cb3c28a1..086da03ae 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,13 @@ GNU coreutils NEWS -*- outline -*- All files would be processed correctly, but the exit status was incorrect. [bug introduced in coreutils-9.0] +** Changes in behavior + + timeout --foreground --kill-after=... will now exit with status 137 + if the kill signal was sent, which is consistent with the behaviour + when the --foreground option is not specified. This allows users to + distinguish if the command was more forcefully terminated. + * Noteworthy changes in release 9.0 (2021-09-24) [stable] diff --git a/doc/coreutils.texi b/doc/coreutils.texi index e3ecbdcf8..02aae4ef4 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -18326,9 +18326,6 @@ exit status 137, regardless of whether that signal is sent to @var{command} or to @command{timeout} itself, i.e., these cases cannot be distinguished. In the latter case, the @var{command} process may still be alive after @command{timeout} has forcefully been terminated. -However if the @option{--foreground} option is specified then -@command{timeout} will not send any signals to its own process, -and so it will exit with one of the other exit status values detailed above. Examples: diff --git a/src/timeout.c b/src/timeout.c index 34d792640..650563461 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -593,6 +593,11 @@ main (int argc, char **argv) unblock_signal (sig); raise (sig); } + /* Allow users to distinguish if command was forcably killed. + Needed with --foreground where we don't send SIGKILL to + the timeout process itself. */ + if (timed_out && sig == SIGKILL) + preserve_status = true; status = sig + 128; /* what sh returns for signaled processes. */ } else diff --git a/tests/misc/timeout.sh b/tests/misc/timeout.sh index 44ca450d8..295a95773 100755 --- a/tests/misc/timeout.sh +++ b/tests/misc/timeout.sh @@ -42,7 +42,10 @@ returns_ 124 timeout --preserve-status .1 sleep 10 && fail=1 # kill delay. Note once the initial timeout triggers, # the exit status will be 124 even if the command # exits on its own accord. +# exit status should be 128+KILL returns_ 124 timeout -s0 -k1 .1 sleep 10 && fail=1 +# Ensure a consistent exit status with --foreground +returns_ 124 timeout --foreground -s0 -k1 .1 sleep 10 && fail=1 # Ensure 'timeout' is immune to parent's SIGCHLD handler # Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh. -- 2.26.2 --------------AE6F94E2B25B5870F7DD38B0-- From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 12 09:59:41 2021 Received: (at 51135) by debbugs.gnu.org; 12 Oct 2021 13:59:41 +0000 Received: from localhost ([127.0.0.1]:42751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maIJh-0000EO-DV for submit@debbugs.gnu.org; Tue, 12 Oct 2021 09:59:41 -0400 Received: from donkey.elm.relay.mailchannels.net ([23.83.212.49]:9496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1maIJX-0000Di-TW for 51135@debbugs.gnu.org; Tue, 12 Oct 2021 09:59:40 -0400 X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5CB4992317C; Tue, 12 Oct 2021 13:59:29 +0000 (UTC) Received: from mailgw-01.dd24.net (100-96-133-192.trex.outbound.svc.cluster.local [100.96.133.192]) (Authenticated sender: instrampxe0y3a) by relay.mailchannels.net (Postfix) with ESMTPA id 4E7869230FA; Tue, 12 Oct 2021 13:59:28 +0000 (UTC) X-Sender-Id: instrampxe0y3a|x-authsender|calestyo@scientia.net Received: from mailgw-01.dd24.net (mailgw-01.dd24.net [193.46.215.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.133.192 (trex/6.4.3); Tue, 12 Oct 2021 13:59:29 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: instrampxe0y3a|x-authsender|calestyo@scientia.net X-MailChannels-Auth-Id: instrampxe0y3a X-Minister-Chemical: 5c40d84d6ba1d909_1634047169012_4094015588 X-MC-Loop-Signature: 1634047169012:1489228001 X-MC-Ingress-Time: 1634047169012 Received: from heisenberg.fritz.box (ppp-188-174-65-9.dynamic.mnet-online.de [188.174.65.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: calestyo@scientia.net) by smtp.dd24.net (Postfix) with ESMTPSA id 6FA8F5FC32; Tue, 12 Oct 2021 13:59:26 +0000 (UTC) Message-ID: Subject: Re: bug#51135: timeout: --foreground causes exit status 124, even if KILL was used From: Christoph Anton Mitterer To: =?ISO-8859-1?Q?P=E1draig?= Brady , 51135@debbugs.gnu.org Date: Tue, 12 Oct 2021 15:59:25 +0200 In-Reply-To: <8989a562-0ecb-e65a-3797-cfe90f9097e5@draigBrady.com> References: <8989a562-0ecb-e65a-3797-cfe90f9097e5@draigBrady.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.0-2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 51135 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Tue, 2021-10-12 at 14:50 +0100, Pádraig Brady wrote: > That is a fair point. Thanks for reconsidering :-) > If one is using --kill-after you have to > check for both 124 and 137 anyway to see if it timed out. > It is useful to know whether the command was forcably killed. > Using --foreground to avoid the 137 exit status upon --kill-after > is not until now documented, so we should probably adjust > the exit status to be always 137 if a SIGKILL is sent. > > With the attached we now behave like: > >    $ timeout -v -s0 --foreground -k2 1 sleep 3; echo $? >    timeout: sending signal EXIT to command ‘sleep’ >    timeout: sending signal KILL to command ‘sleep’ >    137 > >    $ timeout -v -s0 -k2 1 sleep 3; echo $? >    timeout: sending signal EXIT to command ‘sleep’ >    timeout: sending signal KILL to command ‘sleep’ >    Killed >    137 Great :-) Cheers, Chris. From unknown Sun Aug 10 20:05:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 10 Nov 2021 12:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator