From nobody Mon Sep 26 21:19:40 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Mbwcr3HZhz4V6FC for ; Mon, 26 Sep 2022 21:19:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Mbwcr1PmMz3nNj for ; Mon, 26 Sep 2022 21:19:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Mbwcr0NZbzv0M for ; Mon, 26 Sep 2022 21:19:40 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 28QLJelx020492 for ; Mon, 26 Sep 2022 21:19:40 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 28QLJd8Z020491 for bugs@FreeBSD.org; Mon, 26 Sep 2022 21:19:39 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 266627] stty -f should be non-blocking Date: Mon, 26 Sep 2022 21:19:40 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: se@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664227180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HqO481DrLnsjiN7PlZc/9ZwKG2ccINKnkMgban+AZn4=; b=voZNHXqrIKLvXhmwSp40QHBCCqQobFntr99vWdJgJ2kvK3oNKpxQwf6NE0pYFuHqaZi7po TmoOMwADvuO+hH3aejjMzs1Opylw//Rf+zuPMfWNFiZ3QSAqesxDvvj/g2rqxsYXQ+yUd1 SGxMuTDfv0bNy4Zx5RHaJYmeT/Y+U0wjJjZITWAXNH2o2GsllbwFksEd3QhaY692mLvXp8 kS+hwbuDXehu/dXbkp1g3lNMANL5v/TAYQO4qx+7TxMeUYqPeA+Btsr1u+owbzEDMuC0zW bX9TKUHbmPP2I4DwsXpvHlaFNHaR3uaG285cXX3qe2nZnxVf+itgR2/gkKb98A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664227180; a=rsa-sha256; cv=none; b=JfxNc4wSN9RSRpfhRZkyyPMhJGktQ65kw+Mv9hHb+qEil+mNuZlSboSjDvHGLvi4TMCK12 1LKkfyksX0qGIUu1tevFSAjhhuyIahMSH1QnWZ3yLlm+0vc0sdH0mZE+mpQQ5CephkEGts 1qcqOq2QsYOb6+tIS3gQAvaQcgrOB2Puf7+H/aUzS5q2cXcgHcMjbaGKy4NbDgKfM8+EOR 1gj9biVvNDHoNVk7QWd5+P7Vp/j3F344QUOC9JlcRwJUsCm7KmSvTeFqSFtIqt83xSSNd2 PulfapM/xB5p74ey9N12igUMMpuxrALw45ojfvVkb3tkjHrvdObpJXu1muuDWQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266627 --- Comment #6 from Stefan E=C3=9Fer --- (In reply to Konstantin Belousov from comment #1) > What would you expect in this case to happen? TIOCSETA override the job > control rules? I do not think this is wise. Or TIOCSETA returning EAGAIN > for instance. The later may be reasonable, but I am not sure how much co= de > would break. Yes, I'm also afraid that making "stty sane &" return with an error code instead of waiting for the terminal to be controlled by the stty process mi= ght cause a violation of POLA. A program that runs in the background must not change the setting of a term= inal in use by the foreground process. Both, blocking until the stty program has control of the terminal, or exiting with an error code seem to be possible approaches. But I can imagine that programs that want to set the terminal mode to "raw"= may rather want to wait for access to the terminal when started in the backgrou= nd, but this would still work if the terminal is not opened with O_NONBLOCK. According to the documentation "stty sane" does not imply O_NONBLOCK, thus = the blocking behavior would still be available. If there is a way that a shell script can determine whether "stty sane" wou= ld block, I could skip that call in the script running in the background. But I do not know of a reliable method to detect that case. > Anyway, the later option probably could be done by the attached change. = Do you > know what e.g. Linux does in this case? Linux blocks the system call in the same way as FreeBSD: $ stty sane & [1] 8 $ fg stty sane $ --=20 You are receiving this mail because: You are the assignee for the bug.=