diff options
author | Martin Natano <natano@cvs.openbsd.org> | 2017-03-02 10:38:11 +0000 |
---|---|---|
committer | Martin Natano <natano@cvs.openbsd.org> | 2017-03-02 10:38:11 +0000 |
commit | 74ec58af25dbea2773d924537499c413d0d983dd (patch) | |
tree | 9a9d0c79a40dd17ac87ca0acbfdb4623020c08bc /sbin/reboot/reboot.c | |
parent | 6bfb01fcf4947233b8bf5ffe005dbc1f79a35df0 (diff) |
Add a new sysctl machdep.lidaction. The sysctl works as follows:
machdep.lidaction=0 # do nothing
machdep.lidaction=1 # suspend
machdep.lidaction=2 # hibernate
lidsuspend is just an alias for lidaction, so if you change one, the
other one will have the same value. The plan is to remove
machdep.lidsuspend eventually when people have upgraded their
/ets/sysctl.conf.
discussed with deraadt, who came up with the new MIB name
no objections mlarkin
ok stsp halex jcs
Diffstat (limited to 'sbin/reboot/reboot.c')
-rw-r--r-- | sbin/reboot/reboot.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 266e6df9927..8f1f524d72c 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reboot.c,v 1.35 2016/08/27 01:56:07 guenther Exp $ */ +/* $OpenBSD: reboot.c,v 1.36 2017/03/02 10:38:09 natano Exp $ */ /* $NetBSD: reboot.c,v 1.8 1995/10/05 05:36:22 mycroft Exp $ */ /* @@ -115,13 +115,11 @@ main(int argc, char *argv[]) #ifdef CPU_LIDSUSPEND if (howto & RB_POWERDOWN) { /* Disable suspending on laptop lid close */ - int mib[2]; - int lidsuspend = 0; + int mib[] = {CTL_MACHDEP, CPU_LIDACTION}; + int lidaction = 0; - mib[0] = CTL_MACHDEP; - mib[1] = CPU_LIDSUSPEND; - if (sysctl(mib, 2, NULL, NULL, &lidsuspend, - sizeof(lidsuspend)) == -1 && errno != EOPNOTSUPP) + if (sysctl(mib, 2, NULL, NULL, &lidaction, + sizeof(lidaction)) == -1 && errno != EOPNOTSUPP) warn("sysctl"); } #endif /* CPU_LIDSUSPEND */ |