summaryrefslogtreecommitdiff
path: root/sysutils/psmisc/patches/patch-af
blob: 66f3d4504ce929e78878ad3422cc1481dee0ef6e (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
$NetBSD: patch-af,v 1.4 2001/04/24 16:59:35 jlam Exp $

--- src/pstree.c.orig	Mon Dec 18 00:59:23 2000
+++ src/pstree.c
@@ -22,12 +22,12 @@
 #include <sys/ioctl.h>
 
 #include "comm.h"
+#include "procfs.h"
 
 
 #ifndef MAX_DEPTH
 #define MAX_DEPTH    100
 #endif
-#define PROC_BASE    "/proc"
 
 /* UTF-8 defines by Johan Myreen */
 #define UTF_V	"\342\224\202\277"	/* Vertical line drawing char */
@@ -303,6 +303,7 @@
   const struct passwd *pw;
   int lvl, i, add, offset, len, swapped, info, count, comm_len, first;
   const char *tmp, *here;
+  char tbuf[1024], *pbuf;
   char comm_tmp[5];
 
   if (!current)
@@ -327,7 +328,8 @@
       add = out_int (rep) + 2;
       out_string ("*[");
     }
-  if (current->highlight && (tmp = tgetstr ("md", NULL)))
+  pbuf = tbuf;
+  if (current->highlight && (tmp = tgetstr ("md", &pbuf)))
     tputs (tmp, 1, putchar);
   if ((swapped = print_args) && current->argc < 0)
     out_char ('(');
@@ -366,7 +368,8 @@
     }
   if (info || swapped)
     out_char (')');
-  if (current->highlight && (tmp = tgetstr ("me", NULL)))
+  pbuf = tbuf;
+  if (current->highlight && (tmp = tgetstr ("me", &pbuf)))
     tputs (tmp, 1, putchar);
   if (print_args)
     {
@@ -504,7 +507,7 @@
   while ((de = readdir (dir)) != NULL)
     if ((pid = atoi (de->d_name)) != 0)
       {
-	sprintf (path, "%s/%d/stat", PROC_BASE, pid);
+	sprintf (path, "%s/%d/%s", PROC_BASE, pid, STATUS_FILE);
 	if ((file = fopen (path, "r")) != NULL)
 	  {
 	    empty = 0;
@@ -513,6 +516,10 @@
 		perror (path);
 		exit (1);
 	      }
+#ifdef BSD_44_PROCFS
+	    if (fscanf(file, "%s %*d %d", comm, &ppid) == 2)
+	    { { {
+#else
             fread(readbuf, BUFSIZ, 1, file) ;
             if (ferror(file) == 0) 
             {
@@ -532,11 +539,12 @@
 		(file, "%d (%s) %c %d", &dummy, comm, (char *) &dummy,
 		 &ppid) == 4)
 	      */
+#endif
 		if (!print_args)
 		  add_proc (comm, pid, ppid, st.st_uid, NULL, 0);
 		else
 		  {
-		    sprintf (path, "%s/%d/cmdline", PROC_BASE, pid);
+		    sprintf (path, "%s/%d/%s", PROC_BASE, pid, CMDLINE_FILE);
 		    if ((fd = open (path, O_RDONLY)) < 0)
 		      {
 			perror (path);
@@ -641,7 +649,11 @@
     switch (c)
       {
       case 'a':
+#if defined(BSD_44_PROCFS) && !defined(BSD_PROCFS_CMDLINE)
+	print_args = 0;
+#else
 	print_args = 1;
+#endif
 	break;
       case 'c':
 	compact = 0;