summaryrefslogtreecommitdiffstats
path: root/usr.sbin/apmd
diff options
context:
space:
mode:
authordcoppa <dcoppa@openbsd.org>2015-02-06 08:16:49 +0000
committerdcoppa <dcoppa@openbsd.org>2015-02-06 08:16:49 +0000
commit8d4bc9d5264692cc8a33756d5df9e2720e726cd0 (patch)
tree9b9ef59cbfb63a0bf5454fe2cfe15a62eb6d1e6c /usr.sbin/apmd
parentIEEE sez that 0 is bigger than 1, and IEEE is always right. (diff)
downloadwireguard-openbsd-8d4bc9d5264692cc8a33756d5df9e2720e726cd0.tar.xz
wireguard-openbsd-8d4bc9d5264692cc8a33756d5df9e2720e726cd0.zip
Handle hibernate button in the same way as suspend does: send an
APM_USER_HIBERNATE_REQ event so apmd(8) can get it if it's running. ok mlarkin@, deraadt@, miod@
Diffstat (limited to 'usr.sbin/apmd')
-rw-r--r--usr.sbin/apmd/apmd.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index e73f35a95b3..11eb690f7b1 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmd.c,v 1.74 2015/01/16 06:40:15 deraadt Exp $ */
+/* $OpenBSD: apmd.c,v 1.75 2015/02/06 08:16:50 dcoppa Exp $ */
/*
* Copyright (c) 1995, 1996 John T. Kohl
@@ -348,7 +348,7 @@ int
main(int argc, char *argv[])
{
const char *fname = apmdev;
- int ctl_fd, sock_fd, ch, suspends, standbys, resumes;
+ int ctl_fd, sock_fd, ch, suspends, standbys, hibernates, resumes;
int statonly = 0;
int powerstatus = 0, powerbak = 0, powerchange = 0;
int noacsleep = 0;
@@ -487,7 +487,7 @@ main(int argc, char *argv[])
continue;
if (ev->ident == ctl_fd) {
- suspends = standbys = resumes = 0;
+ suspends = standbys = hibernates = resumes = 0;
syslog(LOG_DEBUG, "apmevent %04x index %d",
(int)APM_EVENT_TYPE(ev->data),
(int)APM_EVENT_INDEX(ev->data));
@@ -503,6 +503,9 @@ main(int argc, char *argv[])
case APM_STANDBY_REQ:
standbys++;
break;
+ case APM_USER_HIBERNATE_REQ:
+ hibernates++;
+ break;
#if 0
case APM_CANCEL:
suspends = standbys = 0;
@@ -536,6 +539,8 @@ main(int argc, char *argv[])
suspend(ctl_fd);
else if (standbys)
stand_by(ctl_fd);
+ else if (hibernates)
+ hibernate(ctl_fd);
else if (resumes) {
do_etc_file(_PATH_APM_ETC_RESUME);
syslog(LOG_NOTICE,