From owner-freebsd-mobile@FreeBSD.ORG Fri Jul 5 16:04:51 2013 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AAD10B71 for ; Fri, 5 Jul 2013 16:04:51 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from mail-ie0-f177.google.com (mail-ie0-f177.google.com [209.85.223.177]) by mx1.freebsd.org (Postfix) with ESMTP id 7D08615BE for ; Fri, 5 Jul 2013 16:04:51 +0000 (UTC) Received: by mail-ie0-f177.google.com with SMTP id aq17so5588929iec.22 for ; Fri, 05 Jul 2013 09:04:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=Dx2QQtce2fTDwcWfaCm4Apwkrq/JpHlvi4YpOFRUIrk=; b=Ye44ObiIQCgUd8/xLCRg7zRO2AMAr/jowj0H8FXppjhaXrlzK7zikivrbxlod4lrUW U9uT/ToFzIncT9ZTh1yHgKW9uGMww8hlDF57Eambv9DutBXj7XYBQE+dNZq7XhQdY2aQ gp82ShrIbZ9aptAz5iM/iU2q5buTpUAcPfwApwz6QhVRakjDLGn1sS2h3BJMb/lqMHqk 69UgiUYKLAolCJIwtjKyKP8QOcYbJMGBtQw94bluD222tQe+7caRxIbaMkYP1aq7xq9U oJPrF3a3mkjrg9Gouj9O0iMVlKUG3JJZVtfBfthB+NEPYncsmS59uESX8hjlwAgNb+H1 QFhQ== X-Received: by 10.50.77.80 with SMTP id q16mr28702461igw.3.1373040290485; Fri, 05 Jul 2013 09:04:50 -0700 (PDT) Received: from 53.imp.bsdimp.com (50-78-194-198-static.hfc.comcastbusiness.net. [50.78.194.198]) by mx.google.com with ESMTPSA id t10sm702586igz.9.2013.07.05.09.04.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Jul 2013 09:04:49 -0700 (PDT) Sender: Warner Losh Subject: Re: Adding a hook to shutdown.c & halt (reboot.c) to call a script. Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <20130705130452.GB13495@stack.nl> Date: Fri, 5 Jul 2013 10:04:47 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <2E491218-DFE8-417D-A41E-5DA27BFC94B3@bsdimp.com> References: <201307051252.r65Cq46b046582@fire.js.berklix.net> <20130705130452.GB13495@stack.nl> To: Jilles Tjoelker X-Mailer: Apple Mail (2.1085) X-Gm-Message-State: ALoCoQmWlsDYCciGvdUGECjHMnyR3h6narhcxCIZaT4DucHlS/wqxml03n5O58JzKRgJcHGqHPEK Cc: "Julian H. Stacey" , freebsd-mobile@freebsd.org X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Jul 2013 16:04:51 -0000 On Jul 5, 2013, at 7:04 AM, Jilles Tjoelker wrote: > On Fri, Jul 05, 2013 at 02:52:04PM +0200, Julian H. Stacey wrote: >> Hi mobile@ >> I need ** my laptop to call a script before shutdown,=20 >> (perhaps automaticaly too with something like 'test -e ` etc, >> though perhaps the default should remain with no test) >=20 >> I dont see any hooks in man shutdown or halt ? =20 >> I could hack >> /usr/src/sbin/shutdown/shutdown.c & >> /usr/src/sbin/reboot/reboot.c # (source of halt) >> or does someone have a better idea ? >=20 >> FreeBSD has a mass of scripts etc for system start up, but seems = light >> on close down hooks ? I seem to recall on system 5 there were table >> entries for up & down for lots of things, (though I never got >> on with 5, not lots of others here either, & am not advocating that = route),=20 >> but is there a better way than adding a hook to system("/some_path"); = ? >=20 >> BTW ** What I'm calling manually before halt is my >> http://www.berklix.com/~jhs/bin/.sh/umountusb >> A combo of umounts of USB sticks/disks with plain dos & ufs + also >> mdconfig -d & gbde detach for encrypted file system on both hard >> disk & USB sticks. (When I forget to call it before halt, the >> laptop hangs on USB.) >=20 > shutdown(8) signals init (unless -o is given), which will run > /etc/rc.shutdown from multi-user mode. The same applies to = ctrl+alt+del, > kernel-controlled overheating shutdown, etc. >=20 > reboot(8) and halt(8) do not involve init and do not run any shutdown > scripts. I think they should be changed to signal init (except reboot > -q, halt -q) and should not be used until then. However, there are > apparently some problems with that. I think so too. fasthalt/fastreboot is what I'd call it, but I've come = around to thinking that you're right here. It will be a small hassle for = some people to adapt to the new system, but I think it will be worth it. > The incorrect umount order should perhaps be fixed in the kernel. Agreed. Warner