debug messages should go to stderr (currently debug messages are
buffered if you send them to a pipe)

The sched.h/ncpu bits are remnants from rev 1.46.  Most of this code was
then removed in rev 1.70.

ok?


--- apmd.c.~1.89.~      Thu Oct 31 22:23:07 2019
+++ apmd.c      Fri Nov  1 10:07:21 2019
@@ -36,7 +36,6 @@
 #include <sys/wait.h>
 #include <sys/event.h>
 #include <sys/time.h>
-#include <sys/sched.h>
 #include <sys/sysctl.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -67,9 +66,6 @@ void usage(void);
 int power_status(int fd, int force, struct apm_power_info *pinfo);
 int bind_socket(const char *sn);
 enum apm_state handle_client(int sock_fd, int ctl_fd);
-int  get_avg_idle_mp(int ncpu);
-int  get_avg_idle_up(void);
-void perf_status(struct apm_power_info *pinfo, int ncpu);
 void suspend(int ctl_fd);
 void stand_by(int ctl_fd);
 void hibernate(int ctl_fd);
@@ -96,8 +92,8 @@ logmsg(int prio, const char *msg, ...)
 
        va_start(ap, msg);
        if (debug) {
-               vfprintf(stdout, msg, ap);
-               fprintf(stdout, "\n");
+               vfprintf(stderr, msg, ap);
+               fprintf(stderr, "\n");
        } else {
                vsyslog(prio, msg, ap);
        }
@@ -389,9 +385,6 @@ main(int argc, char *argv[])
        const char *errstr;
        int kq, nchanges;
        struct kevent ev[2];
-       int ncpu_mib[2] = { CTL_HW, HW_NCPU };
-       int ncpu;
-       size_t ncpu_sz = sizeof(ncpu);
 
        while ((ch = getopt(argc, argv, "aACdHLsf:t:S:z:Z:")) != -1)
                switch(ch) {
@@ -503,9 +496,6 @@ main(int argc, char *argv[])
        }
        if (kevent(kq, ev, nchanges, NULL, 0, &sts) == -1)
                error("kevent", NULL);
-
-       if (sysctl(ncpu_mib, 2, &ncpu, &ncpu_sz, NULL, 0) == -1)
-               error("cannot read hw.ncpu", NULL);
 
        for (;;) {
                int rv;

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to