summaryrefslogtreecommitdiffstats
path: root/usr.sbin/acpi/acpiconf/acpiconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/acpi/acpiconf/acpiconf.c')
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c
index 9be6ad8..377f0f9 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.c
+++ b/usr.sbin/acpi/acpiconf/acpiconf.c
@@ -37,10 +37,11 @@
#include <unistd.h>
#include <dev/acpica/acpiio.h>
-
#include <contrib/dev/acpica/acpi.h>
-#define ACPIDEV "/dev/acpi"
+#define ACPIDEV "/dev/acpi"
+#define RC_SUSPEND_PATH "/etc/rc.suspend"
+#define RC_RESUME_PATH "/etc/rc.resume"
static int acpifd;
@@ -68,7 +69,26 @@ acpi_enable_disable(int enable)
static int
acpi_sleep(int sleep_type)
{
- if (ioctl(acpifd, ACPIIO_SETSLPSTATE, &sleep_type) == -1)
+ char cmd[64];
+ int ret;
+
+ /* Run the suspend rc script, if available. */
+ if (access(RC_SUSPEND_PATH, X_OK) == 0) {
+ snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_SUSPEND_PATH,
+ sleep_type);
+ system(cmd);
+ }
+
+ ret = ioctl(acpifd, ACPIIO_SETSLPSTATE, &sleep_type);
+
+ /* Run the resume rc script, if available. */
+ if (access(RC_RESUME_PATH, X_OK) == 0) {
+ snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_RESUME_PATH,
+ sleep_type);
+ system(cmd);
+ }
+
+ if (ret != 0)
err(EX_IOERR, "sleep type (%d) failed", sleep_type);
return (0);
OpenPOWER on IntegriCloud