From owner-freebsd-current@freebsd.org Thu Aug 1 19:37:51 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 64D60C7513; Thu, 1 Aug 2019 19:37:51 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4600v249wtz4BY5; Thu, 1 Aug 2019 19:37:50 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-pg1-f193.google.com with SMTP id n9so28531616pgc.1; Thu, 01 Aug 2019 12:37:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Srl/YOJaNfbL/Koo4yB41YY3eYUoGc6UzuH3efggz+U=; b=YZ19b7tgkn95fhBqvSIaGYUvdYqEXtgv4TtugKo1UwuaErOV2QoPCYi4SdBlMf8BF/ OA880j1Q6UoSMFB5xiUrCCisWFnNcZFHTr3nPUPmllSs0amo04MMKjAZsSr1v46FLeug HfyhNpQP4YH7B7GB8+JNi0eRL1ylNeYr3RKmB6rvEWqKpysVXBvEDeQA5QsArG001hpG RCOZFt1OG/pGS7S7A56i55pwdOiMvwHpfAFiz+u+Xjo3GB8bZYwwmn2AToLTbvJyjhah TP4lpUB/YCiOqmZSrnYMyQqHEnSrlgBYm57iuAKSiDL31AZpJzUAOn3k+/doDFaQVCQr B01A== X-Gm-Message-State: APjAAAWHqo7CcQyBJU6WeGZ355oRF145/3x7mBdYutUzx5fX0f+0174h j+iM8z6BWAB9IQ1/Zp0E4AEsoGUm X-Google-Smtp-Source: APXvYqw4AsV0iQiVR8jSMmIcAGeVe9RbEIhGj1g0JCl1scNrm982O7up3Vl6GZZ/yIykI43Sqa8IVQ== X-Received: by 2002:a63:61cf:: with SMTP id v198mr4438108pgb.217.1564688268417; Thu, 01 Aug 2019 12:37:48 -0700 (PDT) Received: from [192.168.1.36] (broadband-82-140-233-136.atc.tvcom.ru. [82.140.233.136]) by smtp.googlemail.com with ESMTPSA id t7sm71027561pfh.101.2019.08.01.12.37.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 12:37:47 -0700 (PDT) Subject: Re: rc script: manual stop vs system shutdown To: Freddie Cash Cc: Warner Losh , "Rodney W. Grimes" , FreeBSD-Current , freebsd-rc@freebsd.org References: <2e50fb67-8a19-412b-19d2-14f5f20b61f8@FreeBSD.org> <201908011553.x71FrTCd060252@gndrsh.dnsmgr.net> From: Andriy Gapon Openpgp: preference=signencrypt Message-ID: <9b9ca0a6-5aee-74c7-2ac0-a70a81d72593@FreeBSD.org> Date: Thu, 1 Aug 2019 22:37:42 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4600v249wtz4BY5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of agapon@gmail.com designates 209.85.215.193 as permitted sender) smtp.mailfrom=agapon@gmail.com X-Spamd-Result: default: False [-2.15 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[FreeBSD.org]; RWL_MAILSPIKE_GOOD(0.00)[193.215.85.209.rep.mailspike.net : 127.0.0.18]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; RCVD_IN_DNSWL_NONE(0.00)[193.215.85.209.list.dnswl.org : 127.0.5.0]; IP_SCORE(-1.18)[ipnet: 209.85.128.0/17(-3.40), asn: 15169(-2.46), country: US(-0.05)]; FORGED_SENDER(0.30)[avg@FreeBSD.org,agapon@gmail.com]; FREEMAIL_TO(0.00)[gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[136.233.140.82.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[avg@FreeBSD.org,agapon@gmail.com]; MID_RHS_MATCH_FROM(0.00)[] 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: Thu, 01 Aug 2019 19:37:51 -0000 On 01/08/2019 21:53, Freddie Cash wrote: > On Thu, Aug 1, 2019, 11:15 AM 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. > > > A horribly hackish workaround could be to do a "pgrep shutdown" and > "pgrep reboot" and "pgrep halt" in the stop function of the RC script. > If one of those those processes exist, then a system shutdown/reboot is > in progress. > > Not elegant, but could be workable until something nicer is added. I think that shutdown by default sends a signal to init and exits. It's init that kicks off rc.shutdown. -- Andriy Gapon