Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / sysutils / psmisc / patches / patch-af
blob3d16d0e9f17295f10164d949595954813e2105a0
1 $NetBSD$
3 --- src/pstree.c.orig   Mon Dec 18 00:59:23 2000
4 +++ src/pstree.c
5 @@ -22,12 +22,12 @@
6  #include <sys/ioctl.h>
7  
8  #include "comm.h"
9 +#include "procfs.h"
12  #ifndef MAX_DEPTH
13  #define MAX_DEPTH    100
14  #endif
15 -#define PROC_BASE    "/proc"
17  /* UTF-8 defines by Johan Myreen */
18  #define UTF_V  "\342\224\202\277"      /* Vertical line drawing char */
19 @@ -303,6 +303,7 @@
20    const struct passwd *pw;
21    int lvl, i, add, offset, len, swapped, info, count, comm_len, first;
22    const char *tmp, *here;
23 +  char tbuf[1024], *pbuf;
24    char comm_tmp[5];
26    if (!current)
27 @@ -327,7 +328,8 @@
28        add = out_int (rep) + 2;
29        out_string ("*[");
30      }
31 -  if (current->highlight && (tmp = tgetstr ("md", NULL)))
32 +  pbuf = tbuf;
33 +  if (current->highlight && (tmp = tgetstr ("md", &pbuf)))
34      tputs (tmp, 1, putchar);
35    if ((swapped = print_args) && current->argc < 0)
36      out_char ('(');
37 @@ -366,7 +368,8 @@
38      }
39    if (info || swapped)
40      out_char (')');
41 -  if (current->highlight && (tmp = tgetstr ("me", NULL)))
42 +  pbuf = tbuf;
43 +  if (current->highlight && (tmp = tgetstr ("me", &pbuf)))
44      tputs (tmp, 1, putchar);
45    if (print_args)
46      {
47 @@ -504,7 +507,7 @@
48    while ((de = readdir (dir)) != NULL)
49      if ((pid = atoi (de->d_name)) != 0)
50        {
51 -       sprintf (path, "%s/%d/stat", PROC_BASE, pid);
52 +       sprintf (path, "%s/%d/%s", PROC_BASE, pid, STATUS_FILE);
53         if ((file = fopen (path, "r")) != NULL)
54           {
55             empty = 0;
56 @@ -513,6 +516,10 @@
57                 perror (path);
58                 exit (1);
59               }
60 +#ifdef BSD_44_PROCFS
61 +           if (fscanf(file, "%s %*d %d", comm, &ppid) == 2)
62 +           { { {
63 +#else
64              fread(readbuf, BUFSIZ, 1, file) ;
65              if (ferror(file) == 0) 
66              {
67 @@ -532,11 +539,12 @@
68                 (file, "%d (%s) %c %d", &dummy, comm, (char *) &dummy,
69                  &ppid) == 4)
70               */
71 +#endif
72                 if (!print_args)
73                   add_proc (comm, pid, ppid, st.st_uid, NULL, 0);
74                 else
75                   {
76 -                   sprintf (path, "%s/%d/cmdline", PROC_BASE, pid);
77 +                   sprintf (path, "%s/%d/%s", PROC_BASE, pid, CMDLINE_FILE);
78                     if ((fd = open (path, O_RDONLY)) < 0)
79                       {
80                         perror (path);
81 @@ -641,7 +649,11 @@
82      switch (c)
83        {
84        case 'a':
85 +#if defined(BSD_44_PROCFS) && !defined(BSD_PROCFS_CMDLINE)
86 +       print_args = 0;
87 +#else
88         print_args = 1;
89 +#endif
90         break;
91        case 'c':
92         compact = 0;