Re: How to tell if system shutdown is in process
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=WGpP01wt/VtCQnuF1cwKtxfy8uS8zGmD2E0LF4BruY4=; b=dbrKNhz+obeH+Ep2PKPKvA7UO9Ra+HhDGFxfavVBBMkVYNKjejoERoIO8CbwsC9r59 s1km/0StEVZB7I/KjxDlUEUI34aEn0yxYYRG22V1H+ToH+Z5ppgfmGZIkdjkhuYH8vD+ UBzYb3/N/TJ1q869qJnlN4spgX8fBh/129PKI= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=suX08hqLkrHjKr8vwkF6yrEz8BW3fiqGM0bZO6rG9a4ni8XiGyNJgu+o71xlOE5zrb s6JRicRktyjAQekL2FHdT/A4AhFxHUAiHZ54w/AIq58tYGrB7X6rax9iAsmLm5MMSnIW GnEpGc7VL1iZfp5+G+tvLffubLaJtfXGiX+8w= I don't know if the output from the long-running job can be reduced to a file on the file-system. If it can, then the atomicity mechanism that I like a lot is rename(), and the cleanup on restart is to compare the contents of directories (eg by piping ls-1 into while read) and remove any partially generated output. Regards, James.
Message: 2 Date: Thu, 24 Mar 2011 19:21:35 -0700 From: Michael Smith <drivers@mu.org> Subject: Re: How to tell if system shutdown is in process To: Jerry Krinock <jerry@ieee.org> Cc: "darwin-kernel@lists.apple.com Kernel" <darwin-kernel@lists.apple.com> Message-ID: <7E685799-1A52-40DB-8B8E-B4050037FCFA@mu.org> Content-Type: text/plain; charset="us-ascii"
On Mar 24, 2011, at 10:27 AM, Jerry Krinock wrote:
I want my non-GUI command-line program which is launched by user-level launchd to know as early as possible when shutdown is occuring, preferably (for example, if initiated by the console user) immediately when the user clicks the "Shut Down" button in the confirmation dialog, and, at least, before SIGTERMs start getting sent to processes. NSWorkspaceWillPowerOffNotification doesn't work, and IORegisterForSystemPower() doesn't work. Alternatively, I'd like an API to which I could ask before beginning a long task, "Is shutdown in progress?"
You should not do this, because what you are actually asking is "will shutdown be initiated during my long task", which is not something that can be answered.
Instead, you should ask yourself "how can I safely and quickly abort my long task in the rare circumstance where shutdown is signalled while it is in progress?".
= Mike
-- Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile -- Hippocrates
Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
James C