diff options
author | kn <kn@cvs.openbsd.org> | 2021-03-25 20:46:56 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2021-03-25 20:46:56 +0000 |
commit | 785e4d0ebd6c684acedd31a47721d13f90718723 (patch) | |
tree | 506f81025a0f96013017f834753f065381395845 | |
parent | 0586af73c4070b8161cff7881a3934e57c859cf6 (diff) |
Log ioctl failures
Otherwise there is no way to determine why e.g. zzz(8) does not do anything
on certain machines; macppc and arm64 for example have no suspend/resume
suspend at all (for now) and loongson has partial support.
This still does not make `zzz' or `apm -z' report the informative
warning on standar error, but syslog now prints
apmd: system suspending
apmd: battery status: unknown. external power status: not known. estimated battery life 0%
apmd: suspend: Operation not supported
OK benno
-rw-r--r-- | usr.sbin/apmd/apmd.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c index 8e487963d27..58026f7a72b 100644 --- a/usr.sbin/apmd/apmd.c +++ b/usr.sbin/apmd/apmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apmd.c,v 1.101 2021/03/16 09:00:43 kn Exp $ */ +/* $OpenBSD: apmd.c,v 1.102 2021/03/25 20:46:55 kn Exp $ */ /* * Copyright (c) 1995, 1996 John T. Kohl @@ -329,7 +329,8 @@ suspend(int ctl_fd) do_etc_file(_PATH_APM_ETC_SUSPEND); sync(); sleep(1); - ioctl(ctl_fd, APM_IOC_SUSPEND, 0); + if (ioctl(ctl_fd, APM_IOC_SUSPEND, 0) == -1) + logmsg(LOG_WARNING, "%s: %s", __func__, strerror(errno)); } void @@ -340,7 +341,8 @@ stand_by(int ctl_fd) do_etc_file(_PATH_APM_ETC_STANDBY); sync(); sleep(1); - ioctl(ctl_fd, APM_IOC_STANDBY, 0); + if (ioctl(ctl_fd, APM_IOC_STANDBY, 0) == -1) + logmsg(LOG_WARNING, "%s: %s", __func__, strerror(errno)); } void @@ -351,7 +353,8 @@ hibernate(int ctl_fd) do_etc_file(_PATH_APM_ETC_HIBERNATE); sync(); sleep(1); - ioctl(ctl_fd, APM_IOC_HIBERNATE, 0); + if (ioctl(ctl_fd, APM_IOC_HIBERNATE, 0) == -1) + logmsg(LOG_WARNING, "%s: %s", __func__, strerror(errno)); } void |