From 2f1f646e8757007fbc0460c681bd7006b60b9e86 Mon Sep 17 00:00:00 2001 From: kn Date: Thu, 25 Mar 2021 20:46:55 +0000 Subject: [PATCH] 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 --- usr.sbin/apmd/apmd.c | 11 +++++++---- 1 file 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 -- 2.20.1