NetBSD Problem Report #7708
Received: (qmail 3876 invoked from network); 5 Jun 1999 11:26:55 -0000
Message-Id: <199906051126.NAA01589@inetmail.de>
Date: Sat, 5 Jun 1999 13:26:41 +0200 (CEST)
From: Benjamin Lorenz <lorenz@inetmail.de>
Reply-To: lorenz@inetmail.de
To: gnats-bugs@gnats.netbsd.org
Subject: some changes to /usr/sbin/apm and /usr/sbin/apmd
X-Send-Pr-Version: 3.95
>Number: 7708
>Category: bin
>Synopsis: some changes to /usr/sbin/apm and /usr/sbin/apmd
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Jun 05 04:35:00 +0000 1999
>Closed-Date: Wed Jun 04 02:20:53 +0000 2003
>Last-Modified: Wed Jun 04 02:20:53 +0000 2003
>Originator: Benjamin Lorenz
>Release: 1.4
>Organization:
>Environment:
System: NetBSD suag 1.4 NetBSD 1.4 (SUAG) #0: Sat May 15 00:41:48 CEST 1999 lorenz@suag:/var/src/sys/arch/i386/compile/SUAG i386
>Description:
There was a bug in the apmd program which caused it to be _very_
verbose about battery power changes. I also changed some
logging code to produce more compact information. Finally,
in the apm program, I followed the unix tradition that no
feedback to the user is given when everything goes well.
>How-To-Repeat:
>Fix:
First, the diffs for usr.sbin/apmd/apmd.c:
--- apmd.c.orig Sun Dec 20 13:18:57 1998
+++ apmd.c Wed May 12 14:03:09 1999
@@ -110,21 +110,24 @@ power_status(int fd, int force, struct a
if (force ||
bstate.ac_state != last.ac_state ||
bstate.battery_state != last.battery_state ||
- (bstate.minutes_left && bstate.minutes_left < 15) ||
- abs(bstate.battery_life - last.battery_life) > 20) {
+ (bstate.minutes_left && bstate.minutes_left < 11) ||
+ abs(bstate.battery_life - last.battery_life) > 16) {
if (bstate.minutes_left)
- syslog(LOG_NOTICE,
- "battery status: %s. external power status: %s. "
- "estimated battery life %d%% (%d minutes)",
- battstate(bstate.battery_state),
- ac_state(bstate.ac_state), bstate.battery_life,
- bstate.minutes_left);
+ if (bstate.minutes_left > 59)
+ syslog(LOG_NOTICE,
+ "battery power: %d%% (%dh %02dm)",
+ bstate.battery_life,
+ bstate.minutes_left / 60,
+ bstate.minutes_left % 60);
+ else
+ syslog(LOG_NOTICE,
+ "battery power: %d%% (%dm)",
+ bstate.battery_life,
+ bstate.minutes_left);
else
syslog(LOG_NOTICE,
- "battery status: %s. external power status: %s. "
- "estimated battery life %d%%",
- battstate(bstate.battery_state),
- ac_state(bstate.ac_state), bstate.battery_life);
+ "battery power: %d%%",
+ bstate.battery_life);
last = bstate;
}
if (pinfo)
@@ -263,6 +266,7 @@ int howmany;
void
suspend(int ctl_fd)
{
+ syslog(LOG_NOTICE, "system going to sleep (APM suspend)");
do_etc_file(_PATH_APM_ETC_SUSPEND);
sync();
make_noise(2);
@@ -275,6 +279,7 @@ suspend(int ctl_fd)
void
stand_by(int ctl_fd)
{
+ syslog(LOG_NOTICE, "system going to sleep (APM standby)");
do_etc_file(_PATH_APM_ETC_STANDBY);
sync();
make_noise(1);
@@ -290,6 +295,7 @@ void
resume(int ctl_fd)
{
do_etc_file(_PATH_APM_ETC_RESUME);
+ syslog(LOG_NOTICE, "system resumed from APM sleep");
}
int
@@ -456,7 +462,7 @@ main(int argc, char *argv[])
case APM_POWER_CHANGE:
{
struct apm_power_info pinfo;
- power_status(ctl_fd, 1, &pinfo);
+ power_status(ctl_fd, 0, &pinfo);
do_ac_state(pinfo.ac_state);
break;
}
@@ -473,7 +479,6 @@ main(int argc, char *argv[])
stand_by(ctl_fd);
} else if (resumes) {
resume(ctl_fd);
- syslog(LOG_NOTICE, "system resumed from APM sleep");
}
ready--;
}
Now, the diff for usr.sbin/apm/apm.c:
--- apm.c.orig Fri Jan 15 13:12:07 1999
+++ apm.c Wed May 12 13:10:40 1999
@@ -125,7 +125,6 @@ do_zzz(const char *pn, enum apm_action a
if (fd == -1)
err(1, "cannot open connection to APM daemon");
- printf("Suspending system...\n");
exit(send_command(fd, &command, &reply));
}
@@ -261,10 +260,6 @@ main(int argc, char *argv[])
if (ioctl(fd, action == SUSPEND ?
APM_IOC_SUSPEND : APM_IOC_STANDBY, 0) == -1)
err(1, "cannot enter requested power state");
- if (action == SUSPEND)
- printf("System will enter suspend mode in a moment.\n");
- else
- printf("System will enter standby mode in a moment.\n");
exit(0);
} else if (fd == -1)
err(1, "cannot contact APM daemon at socket " _PATH_APM_SOCKET);
@@ -316,10 +311,7 @@ main(int argc, char *argv[])
}
switch (reply.newstate) {
case SUSPEND:
- printf("System will enter suspend mode in a moment.\n");
- break;
case STANDBY:
- printf("System will enter standby mode in a moment.\n");
break;
default:
break;
>Release-Note:
>Audit-Trail:
From: Dan Winship <danw@MIT.EDU>
To: Benjamin Lorenz <lorenz@inetmail.de>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/7708: some changes to /usr/sbin/apm and /usr/sbin/apmd
Date: Thu, 23 Sep 1999 13:00:48 -0400 (EDT)
The important part of your apmd change (to make it not log every power
change event) was committed to -current a few weeks ago.
As for the apm changes, according to the apm man page:
This command does not wait for positive confirmation that the requested
mode has been entered; to do so would mean the command does not return
until the system resumes from its sleep state.
I believe that this is the reason that it prints messages before
exiting: so that you know it got the message and your system will
suspend/sleep/whatever "soon".
If you really don't like the messages, maybe you could redo the
patch to add a new option (-q presumably) to apm to make it not print
them. That would be less controversial and more likely to be
committed.
-- Dan
State-Changed-From-To: open->feedback
State-Changed-By: fair
State-Changed-When: Wed Jun 4 01:33:56 UTC 2003
State-Changed-Why:
Ben, can you respond to the questions Dan Winship asked in the
response to this problem report?
State-Changed-From-To: feedback->closed
State-Changed-By: fair
State-Changed-When: Wed Jun 4 02:19:58 UTC 2003
State-Changed-Why:
Not surprisingly with a PR this old, the submitter has vanished.
Since this PR was a change-request of a subjective nature, I close it.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.