From owner-freebsd-current@freebsd.org Mon Aug 12 10:46:07 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 759E6ADEA3; Mon, 12 Aug 2019 10:46:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 466XZR0yY1z48gv; Mon, 12 Aug 2019 10:46:06 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x7CAjoGY051464 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 12 Aug 2019 13:45:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x7CAjoGY051464 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x7CAjo7W051463; Mon, 12 Aug 2019 13:45:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 12 Aug 2019 13:45:50 +0300 From: Konstantin Belousov To: Andriy Gapon Cc: Ian Lepore , Warner Losh , "Rodney W. Grimes" , FreeBSD Current , freebsd-rc@freebsd.org Subject: Re: rc script: manual stop vs system shutdown Message-ID: <20190812104550.GA2738@kib.kiev.ua> References: <2e50fb67-8a19-412b-19d2-14f5f20b61f8@FreeBSD.org> <201908011553.x71FrTCd060252@gndrsh.dnsmgr.net> <91d1a853-c449-481a-b001-7c1f54e28fdd@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <91d1a853-c449-481a-b001-7c1f54e28fdd@FreeBSD.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 466XZR0yY1z48gv X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.91 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.91)[-0.908,0] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Aug 2019 10:46:07 -0000 On Mon, Aug 12, 2019 at 10:46:29AM +0300, Andriy Gapon wrote: > On 01/08/2019 22:51, Ian Lepore wrote: > > On Thu, 2019-08-01 at 21:14 +0300, Andriy Gapon wrote: > >> On 01/08/2019 19:12, Warner Losh wrote: > >>> > >>> > >>> On Thu, Aug 1, 2019, 10:53 AM Rodney W. Grimes > >>> > > >>> wrote: > >>> > >>> > > >>> > Is it possible in an rc script to distinguish between a manual stop > >>> > (e.g., service foo stop) and a stop during a system shutdown (via > >>> > rc.shutdown) ? > >>> > Are there any marker variables for that? > >>> > Or something in the global system state? > >>> > >>> Not that I can think of, but I like this idea, > >>> I am sure that use cases exist. > >>> > >>> > >>> What is the use case that needs to disambiguate the two cases... > >> > >> I have one use case in mind and it's a truly special case. > >> I want rc.d/watchdogd to gracefully stop watchdogd and to disable the > >> watchdog timer when the stop action is requested manually. And I want > >> it to stop watchdogd and set the watchdog timer to a special shutdown > >> timeout during the shutdown. If the special timeout is configured, of > >> course. > >> > > > > The shutdown timeout is already supported: you just set '-x ' > > in watchdogd_flags in rc.conf; no changes to the rc.d script needed. > > > > I think probably you don't even need the first part of what you want. > > The -x arg covers you in the reboot case; most people probably won't > > use it. But if you are using it, and you want to truly kill the dog, > > you would just do "watchdog -t 0" after "service watchdogd stop". If > > you really felt the need to cover that with a single service command, > > then how about using "service watchdogd cancel" where the cancel verb > > does the -t 0 after killing the daemon? > > I guess that there is more than one way to achieve what I want or > something similar to that. > Rather than "expend words" on a theoretical discussion, I decided to do > this: https://reviews.freebsd.org/D21221 > However, I am still open to the discussion and suggestions. > One thing that I would prefer, though, is to make the watchdogd service > as smart as possible -- but not smarter :-) -- that is, I would prefer > to do without adding any new command verbs to it. Did you considered exporting kern_shutdown.c:rebooting as a sysctl ?