summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2018-11-30 18:05:32 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2018-11-30 18:05:32 +0000
commitee5d56740f9d7009e5b1f87227ad1a80903be0f0 (patch)
treed42ec90010fe242b901cdf35c512e4f039a93b55
parenta9869d5f48bb9e71d39d1625c6863567d22faff7 (diff)
log current power status going into and out of suspend, since it may be
interesting to review. it seems the battery status is sometimes stale, but that's another bug. ok kn phessler
-rw-r--r--usr.sbin/apmd/apmd.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index 9975908a03d..20df0bf289c 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmd.c,v 1.81 2017/10/15 15:14:49 jca Exp $ */
+/* $OpenBSD: apmd.c,v 1.82 2018/11/30 18:05:31 tedu Exp $ */
/*
* Copyright (c) 1995, 1996 John T. Kohl
@@ -75,6 +75,7 @@ void perf_status(struct apm_power_info *pinfo, int ncpu);
void suspend(int ctl_fd);
void stand_by(int ctl_fd);
void hibernate(int ctl_fd);
+void resumed(int ctl_fd);
void setperfpolicy(char *policy);
void sigexit(int signo);
void do_etc_file(const char *file);
@@ -315,6 +316,7 @@ void
suspend(int ctl_fd)
{
syslog(LOG_NOTICE, "system suspending");
+ power_status(ctl_fd, 1, NULL);
do_etc_file(_PATH_APM_ETC_SUSPEND);
sync();
sleep(1);
@@ -325,6 +327,7 @@ void
stand_by(int ctl_fd)
{
syslog(LOG_NOTICE, "system entering standby");
+ power_status(ctl_fd, 1, NULL);
do_etc_file(_PATH_APM_ETC_STANDBY);
sync();
sleep(1);
@@ -335,12 +338,22 @@ void
hibernate(int ctl_fd)
{
syslog(LOG_NOTICE, "system hibernating");
+ power_status(ctl_fd, 1, NULL);
do_etc_file(_PATH_APM_ETC_HIBERNATE);
sync();
sleep(1);
ioctl(ctl_fd, APM_IOC_HIBERNATE, 0);
}
+void
+resumed(int ctl_fd)
+{
+ do_etc_file(_PATH_APM_ETC_RESUME);
+ syslog(LOG_NOTICE,
+ "system resumed from sleep");
+ power_status(ctl_fd, 1, NULL);
+}
+
#define TIMO (10*60) /* 10 minutes */
int
@@ -573,9 +586,7 @@ main(int argc, char *argv[])
else if (hibernates)
hibernate(ctl_fd);
else if (resumes) {
- do_etc_file(_PATH_APM_ETC_RESUME);
- syslog(LOG_NOTICE,
- "system resumed from sleep");
+ resumed(ctl_fd);
}
if (powerchange) {