From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 02 07:23:47 2022 Received: (at submit) by debbugs.gnu.org; 2 Apr 2022 11:23:47 +0000 Received: from localhost ([127.0.0.1]:44751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nabr8-0005cl-0W for submit@debbugs.gnu.org; Sat, 02 Apr 2022 07:23:46 -0400 Received: from lists.gnu.org ([209.51.188.17]:59494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1naayj-0004C1-GL for submit@debbugs.gnu.org; Sat, 02 Apr 2022 06:27:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naayh-0007i7-Ff for bug-coreutils@gnu.org; Sat, 02 Apr 2022 06:27:32 -0400 Received: from out29-100.mail.aliyun.com ([115.124.29.100]:49527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1naayd-0000q3-NB for bug-coreutils@gnu.org; Sat, 02 Apr 2022 06:27:30 -0400 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.08119017|-1; BR=01201311R161S88rulernew998_84748_2000303; CH=blue; DM=|CONTINUE|false|; DS=CONTINUE|ham_news_journal|0.00402175-5.17185e-05-0.995927; FP=0|0|0|0|0|0|0|0; HT=ay29a033018047212; MF=yangzhaofeng@arcas-da.com; NM=1; PH=DS; RN=1; RT=1; SR=0; TI=SMTPD_---.NIOzuRa_1648894926; Received: from 10.254.6.5(mailfrom:yangzhaofeng@arcas-da.com fp:SMTPD_---.NIOzuRa_1648894926) by smtp.aliyun-inc.com(33.45.46.134); Sat, 02 Apr 2022 18:22:07 +0800 Message-ID: <71d3971b286d22361181648e3cccda103299af7f.camel@arcas-da.com> Subject: timeout: Program called by timeout cannot interact with tty stdin when timeout is called by exec() From: Zhaofeng Yang To: bug-coreutils@gnu.org Date: Sat, 02 Apr 2022 18:22:06 +0800 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-ba3d8WuCtH930vc7WmZf" User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Received-SPF: permerror client-ip=115.124.29.100; envelope-from=yangzhaofeng@arcas-da.com; helo=out29-100.mail.aliyun.com 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_PERMERROR=0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 02 Apr 2022 07:23:45 -0400 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 (---) --=-ba3d8WuCtH930vc7WmZf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi GNU Team, I found that program called by timeout cannot interact with tty stdin when timeout is called by exec(). A simplest example is `timeout 10 timeout 5 cat`. cat cannot read input from tty stdin. I also tried to run `timeout 5 cat` in other programs by exec(), and all of them cannot read tty stdin. For example, import subprocess subprocess.run(f"timeout 5 cat", shell=3DTrue) with Python 3. I guessed it is a problem with exec(), but trying with the simple C program /* system.c */ #include #include #include int main(const int argc, const char* argv[]){ size_t cmd_length =3D argc; for(int i=3D1; i --=-ba3d8WuCtH930vc7WmZf Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEykKi+HQjzhrg168UEX+gMjEhvYgFAmJII84ACgkQEX+gMjEh vYj8zA//Xg8J3ODy5sdlj3JkJ7sHtHzqXiouXPhExV57GFhVFskhTLZI+TTbS3RH bUB8nq38qKx/i1MiBQXpFbpy7Ojb3u02gJZivxMVeSXorGtD7mr0KcCsjLK159Ux hfRQdG5pzRw6fHCL0kyfnCobbygExrEBtl41FihNsbPGlwt+SQCEvVsUwfx9ccLC avS3pMVrJSk2yhhq1TZiz6/fKBDsPujLmX6zOJOm0O3NyOaeo9ZWkOuBnb35iMF9 Oj2ijMo4dMPp1HpLljE0fS39/Q1KyF6d/dVdhM3Mq+V4S+0M4QBGXyoSICpe4gAL 3POLB5zf6Rc4Hc0eWmwdS27Ak7mP5CEmVg5l50xRAyh4DrveJee8YVagRYTxOxYo B5E+ZdKDxWePEMtAFn5vuZNBrraV+eCYhadva9mn4w6IsiFoV3IwJhV999FNjrQj Q7nMNpJusLLE8pMlfIdqeVbr6AmKQkfIjIMNgvc4W2x6bO+AWDDnF8eas7I6RKzv WliCmLTHCug7KJavOSHoGFDgUK2w++7Zvcq9v/Mng/x3NbPf99WBg5LUlZyBJnOy 8Cd0SGOu0KwD0PIAjXwCkHCukhMxNz9d7wPtnmvuzKeBLYxT2a670hjW3LCbckAG NpLa8rI0JviGRI4QyRwAyPfsTbBcEInqHie22ajNhIu0wYmE/nU= =0mmH -----END PGP SIGNATURE----- --=-ba3d8WuCtH930vc7WmZf-- From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 02 08:21:19 2022 Received: (at 54681) by debbugs.gnu.org; 2 Apr 2022 12:21:20 +0000 Received: from localhost ([127.0.0.1]:44782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nackp-0000ky-Nm for submit@debbugs.gnu.org; Sat, 02 Apr 2022 08:21:19 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:58385) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nacko-0000kq-5I for 54681@debbugs.gnu.org; Sat, 02 Apr 2022 08:21:18 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4KVx3J4hY1z1sXbh; Sat, 2 Apr 2022 14:21:15 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4KVx3H699wz1qqkB; Sat, 2 Apr 2022 14:21:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id kkfsHMXTBlnU; Sat, 2 Apr 2022 14:21:15 +0200 (CEST) X-Auth-Info: rzYgukpYKajN/gBRfPFAANQ2kH8ZGwugt2nlQEW6IZ5AMogdXSF0I3Jny7fi9XQW Received: from igel.home (ppp-46-244-190-59.dynamic.mnet-online.de [46.244.190.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sat, 2 Apr 2022 14:21:15 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id 804552C36AF; Sat, 2 Apr 2022 14:21:14 +0200 (CEST) From: Andreas Schwab To: Zhaofeng Yang Subject: Re: bug#54681: timeout: Program called by timeout cannot interact with tty stdin when timeout is called by exec() References: <71d3971b286d22361181648e3cccda103299af7f.camel@arcas-da.com> X-Yow: I'm ZIPPY!! Are we having FUN yet?? Date: Sat, 02 Apr 2022 14:21:14 +0200 In-Reply-To: <71d3971b286d22361181648e3cccda103299af7f.camel@arcas-da.com> (Zhaofeng Yang's message of "Sat, 02 Apr 2022 18:22:06 +0800") Message-ID: <87tubbu151.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 54681 Cc: 54681@debbugs.gnu.org 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.5 (-) On Apr 02 2022, Zhaofeng Yang wrote: > A simplest example is `timeout 10 timeout 5 cat`. cat cannot read input > from tty stdin. That's because timeout creates a new process group by default. The outer timeout instance already runs in its own process group curtesy of the parent shell (and thus remains in that group), but for the inner instance the process group no longer matches the terminal process group, and thus the children cannot read from the TTY. You can use timeout --foreground to avoid that. $ timeout 10 timeout --foreground 5 cat -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 02 08:25:58 2022 Received: (at 54681) by debbugs.gnu.org; 2 Apr 2022 12:25:58 +0000 Received: from localhost ([127.0.0.1]:44795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nacpK-0000s7-78 for submit@debbugs.gnu.org; Sat, 02 Apr 2022 08:25:58 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]:38603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nacpH-0000rp-PA; Sat, 02 Apr 2022 08:25:56 -0400 Received: by mail-wm1-f48.google.com with SMTP id h10-20020a1c210a000000b0038ccb70e239so436227wmh.3; Sat, 02 Apr 2022 05:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=0OSF/tmUX4WuZ+CQRRvIHIqyC6+oBdITBuiAT2Vg2ag=; b=mBqcsfovblVyGal/bZwDtGPm8oRrMCN9/zrQy44uszsEZe7CijjPJAJVtIg6n+b40q /afZN4k4C/UKjJ0/vzj8gmOS68zPRXZvJJbs+Mzrd3vw9TW8NvcBfq4IFXTwDAffwIs7 HFWanv9sVtxiVoDnWZM/UbQD47GQbIbM0y3VCwxjYJ2fq4b/lxn9kfehDCpqBUH3D7O+ g0dnE9As0uavWuIsvilVY/ExSUHXeGnt9/n5YrUC+ox1FIdCyxlwfrTJoBa8juMirEhh pWYiGkBQXr0kqKVu5fE9L50QNYwDsYZ8VLf3mwSJJd3dd4/HOAt9sYdiWRsZPBIZQZuH aYKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=0OSF/tmUX4WuZ+CQRRvIHIqyC6+oBdITBuiAT2Vg2ag=; b=BizUhpGu/GKVIIko6j9ZECUCFOaSdOFFj7uXX6ZPvw7GpU5M2JmytDZ6Tj0Gy6jnpZ TT8B5l9ZQID/rOC0dTLOConkQlz+V231Xwb2bqbIlqHxCmnKF/HReuNbrT+G8Ls1QItr IPBeWmnOcqYVsilb+RsKoUQiK/mMZraXxXmtEoHno3hXjN9JnnUimS/pzBWl0rLTiKlG SwJXZ8ZpHPYWTXsbvU1m26GPzUt6IWAdHhBktajZ+EKHi/udvKm1aY1lpW755Qjvnu0J hmE6i7kfEldZUyDJ3tlQzbYy2f/4aj3HWJuiHhy0b30uZlVeur2Jj0C10yfZsbanhewS 4anA== X-Gm-Message-State: AOAM532a3Y5+FUDB18xSkeY7UmI6YMjhohpowGYCaZWxmvmSt2iVWm9S DWJymh95GKXwLKc1yNGNhXGJ+UiVLTfiBA== X-Google-Smtp-Source: ABdhPJyGDacBj1RvcOqQrfeB6huJ2tj3o9TkfWGLp5BFbgKdLtTcXKXNnCO433rPpG7D2fiec9a31A== X-Received: by 2002:a05:600c:34c5:b0:38c:30e3:1e6c with SMTP id d5-20020a05600c34c500b0038c30e31e6cmr12618103wmq.144.1648902349505; Sat, 02 Apr 2022 05:25:49 -0700 (PDT) Received: from [192.168.1.9] (95-44-90-175-dynamic.agg2.lod.rsl-rtd.eircom.net. [95.44.90.175]) by smtp.googlemail.com with ESMTPSA id t9-20020a05600c198900b0038cb8b38f9fsm12717082wmq.21.2022.04.02.05.25.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Apr 2022 05:25:48 -0700 (PDT) Message-ID: <76011a5a-095b-635d-5462-70845172065e@draigBrady.com> Date: Sat, 2 Apr 2022 13:25:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Thunderbird/97.0 Subject: Re: bug#54681: timeout: Program called by timeout cannot interact with tty stdin when timeout is called by exec() Content-Language: en-US To: Zhaofeng Yang , 54681@debbugs.gnu.org References: <71d3971b286d22361181648e3cccda103299af7f.camel@arcas-da.com> From: =?UTF-8?Q?P=c3=a1draig_Brady?= In-Reply-To: <71d3971b286d22361181648e3cccda103299af7f.camel@arcas-da.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 54681 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.5 (/) tag 54681 notabug close 54681 stop On 02/04/2022 11:22, Zhaofeng Yang wrote: > Hi GNU Team, > > I found that program called by timeout cannot interact with tty stdin > when timeout is called by exec(). > > A simplest example is `timeout 10 timeout 5 cat`. cat cannot read input > from tty stdin. > > I also tried to run `timeout 5 cat` in other programs by exec(), and > all of them cannot read tty stdin. For example, > > import subprocess > subprocess.run(f"timeout 5 cat", shell=True) timeout has a --foreground option to support this case, with the caveat that if the program forks children, they'll not be timed out. See https://www.gnu.org/software/coreutils/timeout for details. cheers, Pádraig From unknown Sun Aug 17 22:10:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 01 May 2022 11:24:07 +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