Bug 215824 - acpid check for gnome-power-manager running is racy
Summary: acpid check for gnome-power-manager running is racy
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: acpid
Version: 6
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Phil Knirsch
QA Contact:
URL:
Whiteboard:
: 220361 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-11-15 22:10 UTC by Michal Jaegermann
Modified: 2015-03-05 01:17 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-05-16 13:50:21 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Michal Jaegermann 2006-11-15 22:10:33 UTC
Description of problem:

In /etc/acpi/events/power.conf "action" is defined in the following way:

action=/bin/ps awwux \
 | /bin/grep gnome-power-manager | /bin/grep -qv grep \
 || /sbin/shutdown -h now

The problem with this is that if gnome-power-manager is _not_ running,
and /bin/ps will miss that grep, which happens if not that often,
then we will still get a status 0 from that pipeline while it should
be 1.

This action should look like this

 pgrep -f gnome-power-manager >/dev/null || /sbin/shutdown -h now

or, if mucking with /bin/ps is really preferable,
 
 /bin/ps awwux | /bin/grep -q [g]nome-power-manager \
   || /sbin/shutdown -h now

where both ways are not only correct but also simpler.

Version-Release number of selected component (if applicable):
acpid-1.0.4-5

Comment 1 simon 2006-11-16 22:23:07 UTC
I've been having a problem with this script. It's always powering off my machine
regardless of whether gnome power manager is running. Manually running the command;

/bin/ps awwux | /bin/grep gnome-power-manager | /bin/grep -qv grep || echo "Oops"

will yeild no output. However disabling the script causes gnome-power-manager to
close (but this is a separate bug).

Comment 2 Michal Jaegermann 2006-11-16 23:30:12 UTC
> Manually running ... will yeild no output.

Well, one would hope so. :-) This thing tries to say, in a complicated
manner, "if gnome-power-manager is running then, and only then, do not
bother with the stuff at the end of this line".  Usually it even manages
to do that. :-)

When gnome-power-manager is running then it appears that handling of
a power-button event is supposed to happen there but see bug 215822
(sigh, I am eating traling letters in words when typing).

Comment 3 Phil Knirsch 2007-05-16 13:50:21 UTC
That sounds like a real neat fix. I got some reports about this already, but
most were rather unspecific.

I'll include the fix in the next build of acpid.

Thanks,

Read ya, Phil

Comment 4 Phil Knirsch 2007-05-16 13:56:30 UTC
*** Bug 220361 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.