From nobody Thu Oct 06 19:25:18 2022 X-Original-To: dev-commits-src-all@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 4Mk1cG6Cx0z4fHBK; Thu, 6 Oct 2022 19:25:18 +0000 (UTC) (envelope-from git@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 4Mk1cG5mFNz3jyt; Thu, 6 Oct 2022 19:25:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665084318; 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; bh=bukuEBBUFreDBxaGVI6L05ZoROvlGJXt0v27Yy9j5ac=; b=uEv8+ZOUX6gU8oFrhQOK1ed8/vl2E8hs25/BmVdU37M4J3zj3Z3sbOMU7kmXf7SdZlJ2dl i4kSVPAmZvEpFTozcdifYHCzUxXkaorjXO4fKDk7qnHtPvtvy4REKn2pfLfjW+rwWovbJ4 +CKukMkVAN+kG0QkXQiehNLCT87OmarubuKUGor/UaiXCA6hDNKbwmIP0yfUonsx8vwwfo aOjqcvCmRHPmYHFj8+Lu/iMX0mnpb5VYUBf4+3mW5Bram4NTybypDlIQ+KzVH6lWlGWjP3 mvv94ZBmDctoQCuIp4ff78cPeG6RQMfmBTPRobloECLlksyHILuaDEGBqbHpfg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4Mk1cG4pr4zLhr; Thu, 6 Oct 2022 19:25:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 296JPINs055235; Thu, 6 Oct 2022 19:25:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 296JPIEV055234; Thu, 6 Oct 2022 19:25:18 GMT (envelope-from git) Date: Thu, 6 Oct 2022 19:25:18 GMT Message-Id: <202210061925.296JPIEV055234@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: a45048565a1c - main - bsdinstall: Fix race condition when shutting down after installation List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a45048565a1cb4aec118a941237b00da83d56530 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665084318; 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; bh=bukuEBBUFreDBxaGVI6L05ZoROvlGJXt0v27Yy9j5ac=; b=k7YNnXwcEJ8CrS2YncM5ci/0vK847kDaXXkmKjfKSmk4QI+cfTc1ga3yTb7N+8JAy8M+Ru ER+VrpxTWZp62LaXoPyzEMO4GNKgtlEVvCMQy/aKPF0bgMUk5XK+NniHYNCQVPY54jXM6V BbTdYqhQswFKIxu2hVgoQR42mg34pzYEGRjnYqT3Myiy0XM+kO6qhkpqUfp2W+MahaXbju honaa4m2ROiO7PKw07Gq8cpeTGySV1XMg/gpEwxK6h8bbtZVuOKLeyAji3sI6aOf7NGOND RzZqO/VXOPmrph8A0mf+WCfRGIKH+ceDSY4vei9JuRp9P6MQ3eYioMnCSa7PlA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665084318; a=rsa-sha256; cv=none; b=iGWktSQHwneT6dMYBXQF0we2XmTPy0nFzjlcqC5gIsJlrCvivU1yfGLCWxZJR2/OdKayxI s5lV8N+lVKfTVMaHjoOtMudmx0/5xoi343XoatyOGsIQd6UQvDIfhAfo66iRRk34fJMe5P GWKt5ot97zcFbhTVSOOZ0V/ao3+29T1GZsTSFP73qHVd226dVhsqASYRq9Cvk8irJeTK1R AeG+Q7RJbpo2Yp06kjINg+OXY05XKG1czPW3lTEnDWgP/UuzHw4o3JsrzyCRArReIkhBWC 8P/PbRmRbfI1b3rCuLXypv4StDQ1zTsXQFkKN2HprUAltbDIjirfPEXnfYSXkw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=a45048565a1cb4aec118a941237b00da83d56530 commit a45048565a1cb4aec118a941237b00da83d56530 Author: Jessica Clarke AuthorDate: 2022-10-06 19:04:04 +0000 Commit: Jessica Clarke CommitDate: 2022-10-06 19:04:04 +0000 bsdinstall: Fix race condition when shutting down after installation Whilst reboot(8) will block whilst it runs, shutdown(8) does not, daemonizing instead. This means that we must wait after running it, otherwise we will exit and cause the system to attempt to go multi-user in parallel with the shutdown daemon killing init. With the new multi-console support in the installer, runconsoles will immediately kill this daemon, racing with the daemon being able to signal init as desired, and I have seen this race be lost in QEMU with a single CPU. In the past this wasn't such an issue, since shutdown's daemon puts itself in a new session group immediately after fork (and the parent doesn't wait until that has happened, so whilst there's technically a race condition in there where it could receive a SIGHUP from the death of the parent's session leader, in practice this is very unlikely to be hit. This means that the only consequence of this oversight before was that you might get the beginnings of more console output on the way to multi-user and thus the console would look a little confusing. Reviewed by: gjb Fixes: e4505364c087 ("release/rc.local: Provide option to shutdown after installation complete") Fixes: a09af1b7fd95 ("bsdinstall release: Start installer on multiple consoles") Differential Revision: https://reviews.freebsd.org/D36879 --- usr.sbin/bsdinstall/startbsdinstall | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/usr.sbin/bsdinstall/startbsdinstall b/usr.sbin/bsdinstall/startbsdinstall index 0a8207df9bd8..af0fd56e73b3 100644 --- a/usr.sbin/bsdinstall/startbsdinstall +++ b/usr.sbin/bsdinstall/startbsdinstall @@ -78,6 +78,17 @@ $BSDDIALOG_OK) # Install ;; $BSDDIALOG_EXTRA) # Shutdown shutdown -p now + # shutdown(8) daemonizes, with the actual signal to + # init(8) happening in the child, but if we exit the + # script then runconsoles will clean up its children + # thinking we're trying to go multiuser (and if the + # user has disabled multiple console support we'll + # still start trying to go multi-user, which gives + # confusing output on the console if the daemon is slow + # to run). Thus we spin while the daemon runs. + while true; do + sleep 1 + done ;; $BSDDIALOG_CANCEL) # Live CD exit 0