Commit 1b5a731e authored by Timothy Stack's avatar Timothy Stack

Update to compile on fbsd 5.4

parent 93d78f49
/*
AND auto nice daemon - renice programs according to their CPU usage.
Copyright (C) 1999-2004 Patrick Schemitz <schemitz@users.sourceforge.net>
Copyright (C) 1999-2004, 2006 Patrick Schemitz <schemitz@users.sourceforge.net>
http://and.sourceforge.net/
This program is free software; you can redistribute it and/or modify
......@@ -91,13 +91,15 @@ struct and_procent *openbsd_getnext ()
abort();
}
if (openbsd_next >= openbsd_nproc) return NULL;
#if !defined(__FreeBSD_version) || __FreeBSD_version < 500000
strncpy(openbsd_proc.command,openbsd_pt[openbsd_next].kp_proc.p_comm,1023);
openbsd_proc.command[1023] = 0;
openbsd_proc.pid = openbsd_pt[openbsd_next].kp_proc.p_pid;
//
openbsd_proc.uid = openbsd_pt[openbsd_next].kp_eproc.e_pcred.p_ruid;
openbsd_proc.gid = openbsd_pt[openbsd_next].kp_eproc.e_pcred.p_rgid;
#if defined(__FreeBSD__)
# if defined(__FreeBSD__)
openbsd_proc.ppid = openbsd_pt[openbsd_next].kp_eproc.e_ppid;
openbsd_proc.nice = openbsd_pt[openbsd_next].kp_proc.p_nice;
openbsd_proc.stime =
......@@ -107,7 +109,7 @@ struct and_procent *openbsd_getnext ()
openbsd_proc.ctime =
openbsd_pt[openbsd_next].kp_eproc.e_stats.p_cru.ru_utime.tv_sec +
openbsd_pt[openbsd_next].kp_eproc.e_stats.p_cru.ru_stime.tv_sec;
#else
# else
/* Adapted from top(1) port, as found in the misc@openbsd.org archive */
openbsd_proc.ppid = openbsd_pt[openbsd_next].kp_proc.p_ppid; /* FIXME that correct? */
openbsd_proc.nice = openbsd_pt[openbsd_next].kp_proc.p_nice-20;
......@@ -115,10 +117,23 @@ struct and_procent *openbsd_getnext ()
openbsd_pt[openbsd_next].kp_proc.p_sticks +
openbsd_pt[openbsd_next].kp_proc.p_iticks)
/ openbsd_hz;
# endif
#else
strncpy(openbsd_proc.command,openbsd_pt[openbsd_next].ki_comm,1023);
openbsd_proc.command[1023] = 0;
openbsd_proc.pid = openbsd_pt[openbsd_next].ki_pid;
openbsd_proc.nice = openbsd_pt[openbsd_next].ki_nice;
openbsd_proc.uid = openbsd_pt[openbsd_next].ki_ruid;
openbsd_proc.gid = openbsd_pt[openbsd_next].ki_rgid;
openbsd_proc.stime = openbsd_pt[openbsd_next].ki_start.tv_sec;
openbsd_proc.utime =
openbsd_pt[openbsd_next].ki_runtime / (1000 * 1000);
openbsd_proc.ctime =
openbsd_pt[openbsd_next].ki_childtime.tv_sec;
#endif
and_printf(3, "OpenBSD: process %s pid: %d ppid: %d cpu_secs: %d\n",
and_printf(3, "OpenBSD: process %s pid: %d ppid: %d cpu_secs: %d nice: %d\n",
openbsd_proc.command, openbsd_proc.pid, openbsd_proc.ppid,
openbsd_proc.utime);
openbsd_proc.utime, openbsd_proc.nice);
openbsd_next++;
return &openbsd_proc;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment