Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.sbin/apmd Pull up revision 1.17 (requested by chuck):



details:   https://anonhg.NetBSD.org/src/rev/052dc7d15d2d
branches:  netbsd-1-5
changeset: 490579:052dc7d15d2d
user:      he <he%NetBSD.org@localhost>
date:      Sat Feb 03 18:24:01 2001 +0000

description:
Pull up revision 1.17 (requested by chuck):
  Be more picky about running /etc/apm/{battery,line} in response
  to APM_POWER_CHANGE event.  Some BIOSes post this event periodically
  while the battery is charging/discharging, even though there's
  no change in a/c state.  Thus, track a/c state, and only run the
  scripts when a/c state actually changes.

diffstat:

 usr.sbin/apmd/apmd.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 735c26afa092 -r 052dc7d15d2d usr.sbin/apmd/apmd.c
--- a/usr.sbin/apmd/apmd.c      Sat Feb 03 18:19:17 2001 +0000
+++ b/usr.sbin/apmd/apmd.c      Sat Feb 03 18:24:01 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apmd.c,v 1.14 2000/03/04 21:27:18 mycroft Exp $        */
+/*     $NetBSD: apmd.c,v 1.14.4.1 2001/02/03 18:24:01 he Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -306,6 +306,7 @@
     fd_set selcopy;
     struct apm_event_info apmevent;
     int suspends, standbys, resumes;
+    int ac_is_off;
     int noacsleep = 0;
     int lowbattsleep = 0;
     mode_t mode = 0660;
@@ -406,6 +407,7 @@
        struct apm_power_info pinfo;
        power_status(ctl_fd, 1, &pinfo);
        do_ac_state(pinfo.ac_state);
+       ac_is_off = (pinfo.ac_state == APM_AC_OFF);
     }
 
     (void) signal(SIGTERM, sigexit);
@@ -466,7 +468,11 @@
                {
                    struct apm_power_info pinfo;
                    power_status(ctl_fd, 0, &pinfo);
-                   do_ac_state(pinfo.ac_state);
+                   /* power status can change without ac status changing */
+                   if (ac_is_off != (pinfo.ac_state == APM_AC_OFF)) {
+                       do_ac_state(pinfo.ac_state);
+                       ac_is_off = (pinfo.ac_state == APM_AC_OFF);
+                   }
                    break;
                }
                default:



Home | Main Index | Thread Index | Old Index