[Pkg-sysvinit-devel] Bug#565855: eeepc-acpi-scripts: please do not use pidof in /etc/acpi/actions/{suspend, lid, sleep}.sh

Damyan Ivanov dmn at debian.org
Wed Jan 20 11:54:12 UTC 2010


[sysvinit maintainers, we wonder if there is a clean way to detect 
a shutdown in progress]

-=| Damyan Ivanov, Wed, Jan 20, 2010 at 09:24:04AM +0200 |=-
> -=| Daniel Kahn Gillmor, Mon, Jan 18, 2010 at 08:41:11PM -0500 |=-
> > You might want to check with the sysvinit folks to see what the
> > correct way to check for a running /sbin/shutdown might be?  (maybe
> > you want to parse the output of "/sbin/runlevel"?)
> 
> The current code is: 
> > /etc/acpi/actions/suspend.sh:10:if (runlevel | grep -q [06]) || 
> > (pidof '/sbin/shutdown' > /dev/null); then
> > /etc/acpi/actions/suspend.sh-11-    exit 0
> 
> i.e., it is already checking the output of /sbin/runlevel. I am not 
> sure why the check for shutdown is needed, maybe in order to catch 
> timed shutdowns (-t option)?
> 
> Ben, Darren, what do you think, shall the check for a running 
> /sbin/shutdown be just dropped or replaced with something else?

Digging history, this appears to have been added in 
4bc80549f6ecb45a2b645bd83b142482935f133b[1] as a response to #469505[2]

	[1] http://git.debian.org/?p=debian-eeepc/eeepc-acpi-scripts.git;a=commitdiff;h=4bc80549f6ecb45a2b645bd83b142482935f133b
	[2] http://bugs.debian.org/469505

Possible workarounds:

* check the user of the shutdown process. If it is not 'root', then we 
  ignore it and proceed (pgrep can help here)
* check for valid /var/run/shutdown.pid file (existing and the PID 
  inside corresponds to a /sbin/shutdown running as root)
  there is a small chance that we check exactly after the PID file is 
  unlinked and before init is signalled to change the runlevel

Reading shutdown code leads me to believe that there is no perfect 
solution. The intent to shut the machine down is not recorded 
anywhere. shutdown removes its PID file before executing init, and 
init will need some time before 'runlevel' starts to return '0'.

So we may just use the simplest solution (replace 'pidof' with 'pgrep 
-u root') and hope for the best.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20100120/a4919916/attachment.pgp>


More information about the Pkg-sysvinit-devel mailing list