From nobody Mon Mar 20 20:13:28 2023 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 4PgQsj1QSpz40Bn9; Mon, 20 Mar 2023 20:13:29 +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 4PgQsj10T9z3J1h; Mon, 20 Mar 2023 20:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679343209; 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=30sxKtvf/WGWthVU5lg49drDH1kcmogiupuMf/jD988=; b=HHirMvMEYhRoXxgy+WLairk42k7w4oi5aTETwMNPKLUOasJOoT4poMqJOseWcx6N54uU59 uzfyL2/vs6wfbhV/0JMKutBk5ysSbhv2qTwaYdB1TsJ/lBcTOXL+we86ddSP47nNDxd0iS r4oGnxIkDfpXaKZOet1Oi2FobkvWM4dBF7TwzYhZZ+6rq9CdjrcTO6n7xudZnxgjlq8JFZ TlZA2OwfIb4TeHmyWCzO71Kf/taAH0hag5sYwUqRjaArfNAJMlT0P8DwNst84joZkkTwdG S/bLGHlg6ie9mKL4hs/mAUnfMWnnCtvXbz+vAAK4W9lZn7VuZ0h0sh1L6ZU3iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679343209; 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=30sxKtvf/WGWthVU5lg49drDH1kcmogiupuMf/jD988=; b=gL4Knr1uw16KVKpXPrxMTA2LfWeY8pkrMYkqUeNjTlvLv5SYbYTiUmUh9Oa7hOtmC6GUbS MTjgPPBxjbFkr0HW7mIkgskko+PBx183Aaw6Mhs/vcgOgn9ne/pAE5teHEq2VtdwCFogjG IGyFCRhpLupamimCGfrjjSpoj3opC+gwTx7xxbduRoQcS+B+8FefiF6h6c6MGyBVY+Uf8N 0kj5TW0OnGAjA6yvcX94Om0OHp+JsoI4ui9sLQ9fZ2ICq4rggVmZpMHn9iD6duxCuWhqdb 7S57rk0iF/Lv2+JIGW1+xtOAKxigexWjXsRe5ZtC0AQaiOC2YqHo46Nes3K8Cg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679343209; a=rsa-sha256; cv=none; b=FSOiyct9wwRKhRl982fHO8MyifSpQB8ue+D1yeMVdlGBwUf8Jg2haCQOFX/ZZ9SclN06nr 6yuayDWhv96sgHTO4w7sR9FTJGRC9EaMS7uGWbG/vpEAWPLTRNi/8ws6fz/LARjw2W+d75 /69NINBnMo64Mipfk5jGACGiWYcoK9AhHsb/sobQAqfhbC6NAaC0PUrAsih4B1cvTZQRZz 526oCQOsfg3LAAhAixilLUdHHwfYm2gYSD1XaAq8LMdrfPufwqBNwpe0WF4F67FevwJ7YC xbhxSWcGkuQ52xXp0HD5as0rR00q3oc3RjHQrEQge1uhW5Y4hfac2UfbKsWiIg== 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 4PgQsj02lszkWK; Mon, 20 Mar 2023 20:13:29 +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 32KKDSDs033149; Mon, 20 Mar 2023 20:13:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32KKDSkl033148; Mon, 20 Mar 2023 20:13:28 GMT (envelope-from git) Date: Mon, 20 Mar 2023 20:13:28 GMT Message-Id: <202303202013.32KKDSkl033148@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: b7caa912f9df - main - kern_reboot(9): document shutdown_nice() 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b7caa912f9df5f76f189be18afc949a775c8e0fe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=b7caa912f9df5f76f189be18afc949a775c8e0fe commit b7caa912f9df5f76f189be18afc949a775c8e0fe Author: Mitchell Horne AuthorDate: 2023-03-20 19:58:16 +0000 Commit: Mitchell Horne CommitDate: 2023-03-20 20:12:12 +0000 kern_reboot(9): document shutdown_nice() Reviewed by: markj, Pau Amma MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39134 --- share/man/man9/Makefile | 3 ++- share/man/man9/kern_reboot.9 | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index b03993b57860..3bfc72b69dc6 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -1335,7 +1335,8 @@ MLINKS+=intr_event.9 intr_event_add_handler.9 \ intr_event.9 intr_event_remove_handler.9 \ intr_event.9 intr_priority.9 MLINKS+=KASSERT.9 MPASS.9 -MLINKS+=kern_reboot.9 reboot.9 +MLINKS+=kern_reboot.9 reboot.9 \ + kern_reboot.9 shutdown_nice.9 MLINKS+=kern_yield.9 maybe_yield.9 \ kern_yield.9 should_yield.9 MLINKS+=kernacc.9 useracc.9 diff --git a/share/man/man9/kern_reboot.9 b/share/man/man9/kern_reboot.9 index e88574cce0d1..d120a437c521 100644 --- a/share/man/man9/kern_reboot.9 +++ b/share/man/man9/kern_reboot.9 @@ -45,7 +45,8 @@ .Dt REBOOT 9 .Os .Sh NAME -.Nm kern_reboot +.Nm kern_reboot , +.Nm shutdown_nice .Nd reboot, halt, or power off the system .Sh SYNOPSIS .In sys/types.h @@ -54,6 +55,8 @@ .Vt extern int rebooting; .Ft void .Fn kern_reboot "int howto" +.Ft void +.Fn shutdown_nice "int howto" .In sys/eventhandler.h .Fn EVENTHANDLER_REGISTER "shutdown_pre_sync" "shutdown_fn" "private" "priority" .Fn EVENTHANDLER_REGISTER "shutdown_post_sync" "shutdown_fn" "private" "priority" @@ -147,12 +150,42 @@ the section of the .Xr panic 9 man page. +.Pp +The +.Fn shutdown_nice +function is the intended path for performing a clean reboot or shutdown when +the system is operating under normal conditions. +Calling this function will send a signal to the +.Xr init 8 +process, instructing it to perform a shutdown. +When +.Xr init 8 +has cleanly terminated its children, it will perform the +.Xr reboot 2 +system call, which in turn calls +.Fn kern_reboot . +.Pp +If +.Fn shutdown_nice +is called before the +.Xr init 8 +process has been spawned, or if the system has panicked or otherwise halted, +.Fn kern_reboot +will be called directly. .Sh RETURN VALUES The .Fn kern_reboot function does not return. +.Pp +The +.Fn shutdown_nice +function will usually return to its caller, having initiated the asynchronous +system shutdown. +It will not return when called from a panic or debugger context, or during +early boot. .Sh SEE ALSO .Xr reboot 2 , +.Xr init 8 , .Xr EVENTHANDLER 9 , .Xr panic 9 , .Xr vfs_unmountall 9