$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 #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;