On 09/22/15 12:13, Jung-uk Kim wrote: >> I didn't want to pollute init with arch-dependent hacks. Anyway, >> the attached patch should do what you want (not tested). > > Or a simpler hack with sysctl(3) instead of ioctl(2).
Right, this is more like what I was thinking. (I can write patches myself btw -- I was asking for help with figuring out the right solution, not with the coding itself!) A couple things I'm not sure about though: > + /* Temporarily block any suspend requests. */ > + len = sizeof(blocked); > + block = 1; > + if (sysctlbyname("debug.acpi.sleep_blocked", &blocked, &len, > + &block, sizeof(block)) == -1) > + blocked = 0; Wouldn't it make sense to wrap this in "if (Reboot)"? That way it would block suspend for poweroff / halt / reboot, but not for dropping to single-user mode. > +#if defined(__amd64__) || defined(__i386__) > + /* Unblock suspend requests. */ > + if (!blocked) > + sysctlbyname("debug.acpi.sleep_blocked", NULL, NULL, > + &blocked, sizeof(blocked)); > +#endif > + And if we restrict the blocking to only happen if (Reboot), is there any point unblocking suspend when we're about to call reboot(2)? -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid _______________________________________________ freebsd-acpi@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-acpi To unsubscribe, send any mail to "freebsd-acpi-unsubscr...@freebsd.org"