summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroga <oga@openbsd.org>2009-02-26 17:21:56 +0000
committeroga <oga@openbsd.org>2009-02-26 17:21:56 +0000
commitd8a2923b730e874efd12bc17ecad849205ebf4c3 (patch)
tree34ec88b8d5e83e09b02b5520a896ee5d3e219568
parentAdd a two new ioctls to the apm(4) interface. (diff)
downloadwireguard-openbsd-d8a2923b730e874efd12bc17ecad849205ebf4c3.tar.xz
wireguard-openbsd-d8a2923b730e874efd12bc17ecad849205ebf4c3.zip
Change apmd to use the new _REQ ioctls for zzz, this gives X a chance to
vt-switch internally so it's likely to actually survive the suspend. tested by beck@, sthen@. ok deraadt@
-rw-r--r--usr.sbin/apmd/apmd.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index 11a3b67b8ca..c455bfec774 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmd.c,v 1.52 2009/02/26 00:29:39 tedu Exp $ */
+/* $OpenBSD: apmd.c,v 1.53 2009/02/26 17:21:56 oga Exp $ */
/*
* Copyright (c) 1995, 1996 John T. Kohl
@@ -79,6 +79,8 @@ int get_avg_idle_up(void);
void perf_status(struct apm_power_info *pinfo, int ncpu);
void suspend(int ctl_fd);
void stand_by(int ctl_fd);
+void suspend_req(int ctl_fd);
+void stand_by_req(int ctl_fd);
void setperf(int new_perf);
void sigexit(int signo);
void do_etc_file(const char *file);
@@ -485,6 +487,26 @@ stand_by(int ctl_fd)
ioctl(ctl_fd, APM_IOC_STANDBY, 0);
}
+void
+suspend_req(int ctl_fd)
+{
+ /* let the user get their finger off the enter key before we suspend */
+ sleep(1);
+ ioctl(ctl_fd, APM_IOC_SUSPEND_REQ, 0);
+ /* give X a chance to do things */
+ sleep(2);
+}
+
+void
+stand_by_req(int ctl_fd)
+{
+ /* let the user get their finger off the enter key before we suspend */
+ sleep(1);
+ ioctl(ctl_fd, APM_IOC_STANDBY_REQ, 0);
+ /* give X a chance to do things */
+ sleep(2);
+}
+
#define TIMO (10*60) /* 10 minutes */
int
@@ -736,10 +758,10 @@ main(int argc, char *argv[])
case NORMAL:
break;
case SUSPENDING:
- suspend(ctl_fd);
+ suspend_req(ctl_fd);
break;
case STANDING_BY:
- stand_by(ctl_fd);
+ stand_by_req(ctl_fd);
break;
}
}