summaryrefslogtreecommitdiff
path: root/sysutils/libgtop2/patches/patch-ab
blob: d3c645517159346ca3a3ebf1e0a36aacbb56ab4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
$NetBSD: patch-ab,v 1.4 2006/03/03 15:02:13 adam Exp $

--- sysdeps/freebsd/proctime.c.orig	2005-02-23 08:20:45.000000000 +0000
+++ sysdeps/freebsd/proctime.c
@@ -57,7 +57,7 @@ glibtop_init_proc_time_p (glibtop *serve
  * system, and interrupt time usage.
  */
 
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__DragonFly__)
 
 #ifndef __FreeBSD__
 static void
@@ -137,21 +137,20 @@ glibtop_get_proc_time_p (glibtop *server
 #if (defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000))
 	if (server->sysdeps.proc_time == 0)
 		return;
-
-#ifndef __bsdi__
-	sprintf (filename, "/proc/%d/mem", (int) pid);
-	if (stat (filename, &statb)) return;
-#endif
 #endif
 
 	/* Get the process information */
 	pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, &count);
-	if ((pinfo == NULL) || (count != 1))
-		glibtop_error_io_r (server, "kvm_getprocs (%d)", pid);
+	if ((pinfo == NULL) || (count != 1)) {
+		glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+		return;
+	}
 
 #if defined(__FreeBSD__) && (__FreeBSD_version >= 500013)
 	buf->rtime = pinfo [0].ki_runtime;
-#elif (defined __FreeBSD__) && (__FreeBSD_version <= 500013)
+#elif defined(__DragonFly__)
+	buf->rtime = pinfo[0].kp_eproc.e_uticks / 100000;
+#elif (defined __FreeBSD__) && (__FreeBSD_version <= 500013)
 	buf->rtime = pinfo [0].kp_proc.p_runtime;
 #else
 	buf->rtime = tv2sec (pinfo [0].kp_proc.p_rtime);
@@ -193,18 +192,26 @@ glibtop_get_proc_time_p (glibtop *server
        if ((pinfo [0].ki_flag & P_INMEM)) {
 #endif
            buf->utime = pinfo [0].ki_runtime;
-           buf->stime = 0; /* XXX */
+		   buf->stime = tv2sec (pinfo [0].ki_rusage.ru_stime);
            buf->cutime = tv2sec (pinfo [0].ki_childtime);
-           buf->cstime = 0; /* XXX */
+#if __FreeBSD_version >= 600000
+		   buf->cstime = tv2sec (pinfo [0].ki_rusage_ch.ru_stime);
+#else
+		   buf->cstime = 0;
+#endif
            buf->start_time = tv2sec (pinfo [0].ki_start);
            buf->flags = _glibtop_sysdeps_proc_time_user;
        }
 
 	glibtop_suid_enter (server);
 
-#elif (__FreeBSD_version <= 500013)
+#elif defined(__DragonFly__) || (defined(__FreeBSD__) || (__FreeBSD_version <= 500013))
 
+#if defined(__DragonFly__)
+        if ((pinfo [0].kp_proc.p_flag & P_SWAPPEDOUT) == 0 &&
+#else
         if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+#endif
             kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
                        (unsigned long) &u_addr->u_stats,
                        (char *) &pstats, sizeof (pstats)) == sizeof (pstats))
@@ -214,13 +221,21 @@ glibtop_get_proc_time_p (glibtop *server
                        buf->stime = tv2sec (pinfo[0].kp_eproc.e_stats.p_ru.ru_stime);
                        buf->cutime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_utime);
                        buf->cstime = tv2sec (pinfo[0].kp_eproc.e_stats.p_cru.ru_stime);
+#if defined(__DragonFly__)
+                       buf->start_time = tv2sec (pinfo[0].kp_thread.td_start);
+#else
                        buf->start_time = tv2sec (pinfo[0].kp_eproc.e_stats.p_start);
+#endif
                        buf->flags = _glibtop_sysdeps_proc_time_user;
                        glibtop_suid_leave (server);
 		}
 #else
 
+#if defined(__DragonFly__)
+        if ((pinfo [0].kp_proc.p_flag & P_SWAPPEDOUT) == 0 &&
+#else
 	if ((pinfo [0].kp_proc.p_flag & P_INMEM) &&
+#endif
 	    kvm_uread (server->machine.kd, &(pinfo [0]).kp_proc,
 		       (unsigned long) &u_addr->u_stats,
 		       (char *) &pstats, sizeof (pstats)) == sizeof (pstats))