]> granicus.if.org Git - psmisc/commitdiff
-A flag for pstree
authorCraig Small <csmall@users.sourceforge.net>
Sat, 24 Apr 2004 12:47:20 +0000 (12:47 +0000)
committerCraig Small <csmall@users.sourceforge.net>
Sat, 24 Apr 2004 12:47:20 +0000 (12:47 +0000)
ChangeLog
autom4te.cache/requests
doc/pstree.1
src/pstree.c

index 3e87c493ce1dc0e40a5fff0db9fc99c14a5e0d88..5833b16efcebd8c98f967585f465c6956861f40c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,9 +3,11 @@ not-yet-released
        * Sven Dahl provides a patch for using psmisc with uclibc
        * Sid flag in options is d not S. SF#791537
        * Fixed typo in checking ss_family SF#845292
-       * Lines not truncated using UTF-8 SF Patch: #757164
+       * Lines not truncated using UTF-8 SF Patch: #757164 Debian: #151523
        * Case insensitve matching with -I flags SF Patch: #740662
        * inode and devices use ino_t and dev_t SF#: 
+       * Allow pstree to use ASCII characters with -A flag, patch by
+         Branden Robinson Debian: #240973
 
 2004-04-05  gettextize  <bug-gnu-gettext@gnu.org>
 
index 504d659534ffd9ea46634ff1c6165b7ae6d74f3f..6f79e10d327ec43c3b3a2252cbd9511f14fadb25 100644 (file)
                       {
                         'm4_pattern_forbid' => 1,
                         'AC_CONFIG_LIBOBJ_DIR' => 1,
-                        'AC_C_VOLATILE' => 1,
                         'AC_TYPE_OFF_T' => 1,
+                        'AC_C_VOLATILE' => 1,
                         'AC_FUNC_CLOSEDIR_VOID' => 1,
                         'AC_REPLACE_FNMATCH' => 1,
                         'AC_PROG_LIBTOOL' => 1,
                         'AC_FUNC_STAT' => 1,
-                        'AC_FUNC_WAIT3' => 1,
                         'AC_HEADER_TIME' => 1,
-                        'AC_FUNC_LSTAT' => 1,
-                        'AC_STRUCT_TM' => 1,
+                        'AC_FUNC_WAIT3' => 1,
                         'AM_AUTOMAKE_VERSION' => 1,
-                        'AC_FUNC_GETMNTENT' => 1,
+                        'AC_STRUCT_TM' => 1,
+                        'AC_FUNC_LSTAT' => 1,
                         'AC_TYPE_MODE_T' => 1,
+                        'AC_FUNC_GETMNTENT' => 1,
                         'AC_FUNC_STRTOD' => 1,
                         'AC_CHECK_HEADERS' => 1,
                         'AC_FUNC_STRNLEN' => 1,
                         'AC_STRUCT_ST_BLOCKS' => 1,
                         'AC_TYPE_SIGNAL' => 1,
                         'AC_TYPE_UID_T' => 1,
-                        'AC_PROG_MAKE_SET' => 1,
                         'AC_CONFIG_AUX_DIR' => 1,
-                        'm4_pattern_allow' => 1,
+                        'AC_PROG_MAKE_SET' => 1,
                         'sinclude' => 1,
+                        'm4_pattern_allow' => 1,
                         'AC_DEFINE_TRACE_LITERAL' => 1,
                         'AC_FUNC_STRERROR_R' => 1,
                         'AC_PROG_CC' => 1,
-                        'AC_FUNC_FORK' => 1,
                         'AC_DECL_SYS_SIGLIST' => 1,
-                        'AC_FUNC_STRCOLL' => 1,
+                        'AC_FUNC_FORK' => 1,
                         'AC_FUNC_VPRINTF' => 1,
+                        'AC_FUNC_STRCOLL' => 1,
                         'AC_PROG_YACC' => 1,
                         'AC_INIT' => 1,
                         'AC_STRUCT_TIMEZONE' => 1,
                         'AM_MAINTAINER_MODE' => 1,
                         'AC_FUNC_UTIME_NULL' => 1,
                         'AC_FUNC_SELECT_ARGTYPES' => 1,
-                        'AC_HEADER_STAT' => 1,
                         'AC_FUNC_STRFTIME' => 1,
-                        'AC_PROG_CPP' => 1,
+                        'AC_HEADER_STAT' => 1,
                         'AC_C_INLINE' => 1,
-                        'AC_PROG_LEX' => 1,
-                        'AC_C_CONST' => 1,
+                        'AC_PROG_CPP' => 1,
                         'AC_TYPE_PID_T' => 1,
+                        'AC_C_CONST' => 1,
+                        'AC_PROG_LEX' => 1,
                         'AC_CONFIG_FILES' => 1,
                         'include' => 1,
                         'AC_FUNC_SETVBUF_REVERSED' => 1,
                         'AC_PROG_INSTALL' => 1,
                         'AM_GNU_GETTEXT' => 1,
-                        'AC_FUNC_OBSTACK' => 1,
                         'AC_CHECK_LIB' => 1,
+                        'AC_FUNC_OBSTACK' => 1,
                         'AC_FUNC_MALLOC' => 1,
                         'AC_FUNC_GETGROUPS' => 1,
                         'AC_FUNC_GETLOADAVG' => 1,
                         'AH_OUTPUT' => 1,
                         'AC_FUNC_FSEEKO' => 1,
                         'AM_PROG_CC_C_O' => 1,
-                        'AC_FUNC_MKTIME' => 1,
-                        'AC_CANONICAL_SYSTEM' => 1,
                         'AM_CONDITIONAL' => 1,
+                        'AC_CANONICAL_SYSTEM' => 1,
+                        'AC_FUNC_MKTIME' => 1,
                         'AC_CONFIG_HEADERS' => 1,
                         'AC_HEADER_SYS_WAIT' => 1,
-                        'AC_PROG_LN_S' => 1,
                         'AC_FUNC_MEMCMP' => 1,
+                        'AC_PROG_LN_S' => 1,
                         'm4_include' => 1,
                         'AC_HEADER_DIRENT' => 1,
                         'AC_CHECK_FUNCS' => 1
index c9a8640251d4d027b5ecf1c70890311eaaef9dbc..391fe35ff2912593283dae184e9211ac5e9ded6a 100644 (file)
@@ -11,7 +11,7 @@ pstree \- display a tree of processes
 .RB [ \-n ]
 .RB [ \-p ]
 .RB [ \-u ]
-.RB [ \-G | \-U ]
+.RB [ \-A | \-G | \-U ]
 .RB [ \fIpid\fB | \fIuser\fB]
 .br
 .B pstree
@@ -48,6 +48,8 @@ has happened.  This is useful for when \fBpstree\fR is run in a xterminal.
 .IP \fB\-a\fP
 Show command line arguments. If the command line of a process is swapped out,
 that process is shown in parentheses. \fB\-a\fP implicitly disables compaction.
+.IP \fB\-A\fP
+Use ASCII characters to draw the tree.
 .IP \fB\-c\fP
 Disable compaction of identical subtrees. By default, subtrees are compacted
 whenever possible.
index dcbce900dbef9b00c891712d15feaf466fdb97e3..50fcff998eceb314c20904b9cc951e4d22f81f60 100644 (file)
@@ -15,6 +15,8 @@
 #include <getopt.h>
 #include <pwd.h>
 #include <dirent.h>
+#include <curses.h>
+#include <term.h>
 #include <termios.h>
 #include <termcap.h>
 #include <langinfo.h>
@@ -715,9 +717,10 @@ static void
 usage (void)
 {
   fprintf (stderr, _("usage: pstree [ -a ] [ -c ] [ -h | -H pid ] [ -l ] [ -n ] [ -p ] [ -u ]\n"));
-  fprintf (stderr, _("              [ -G | -U ] [ pid | user]\n"));
+  fprintf (stderr, _("              [ -A | -G | -U ] [ pid | user]\n"));
   fprintf (stderr, _("       pstree -V\n\n"));
   fprintf (stderr, _("    -a     show command line arguments\n"));
+  fprintf (stderr, _("    -A     use ASCII line drawing characters\n"));
   fprintf (stderr, _("    -c     don't compact identical subtrees\n"));
   fprintf (stderr, _("    -h     highlight current process and its ancestors\n"));
   fprintf (stderr, _("    -H pid highlight process \"pid\" and its ancestors\n"));
@@ -756,6 +759,7 @@ main (int argc, char **argv)
   const struct passwd *pw;
   pid_t pid, highlight;
   char termcap_area[1024];
+  char *termname;
   int c;
   char *tmpstr;
 
@@ -776,23 +780,45 @@ main (int argc, char **argv)
       wait_end=1;
   }
 
+  /*
+   * Attempt to figure out a good default symbol set.  Will be overriden by
+   * command-line options, if given.
+   */
+
+  if (!strcmp(nl_langinfo(CODESET), "UTF-8")) {
+    /* Use UTF-8 symbols if the locale's character set is UTF-8. */
+    sym = &sym_utf;
+  } else if ((termname = getenv ("TERM")) && \
+             (strlen (termname) > 0) && \
+             (setupterm (NULL, 1 /* stdout */, NULL) == OK) && \
+             (tigetstr ("acsc") > 0)) {
+    /*
+     * Failing that, if TERM is defined, a non-null value, and the terminal
+     * has the VT100 graphics charset, use it.
+     */
+    sym = &sym_vt100;
+  } else {
+    /* Otherwise, fall back to ASCII. */
+    sym = &sym_ascii;
+  }
 
 #ifdef FLASK_LINUX
-  while ((c = getopt (argc, argv, "acGhH:npluUVsx")) != EOF)
+  while ((c = getopt (argc, argv, "aAcGhH:npluUVsx")) != EOF)
 #else  /*FLASK_LINUX*/
-  while ((c = getopt (argc, argv, "acGhH:npluUV")) != EOF)
+  while ((c = getopt (argc, argv, "aAcGhH:npluUV")) != EOF)
 #endif /*FLASK_LINUX*/
     switch (c)
       {
       case 'a':
        print_args = 1;
        break;
+      case 'A':
+       sym = &sym_ascii;
+       break;
       case 'c':
        compact = 0;
        break;
       case 'G':
-       if (sym != &sym_ascii)
-         usage ();
        sym = &sym_vt100;
        break;
       case 'h':
@@ -831,8 +857,6 @@ main (int argc, char **argv)
        user_change = 1;
        break;
       case 'U':
-       if (sym != &sym_ascii)
-         usage ();
        sym = &sym_utf;
        break;
       case 'V':
@@ -863,14 +887,6 @@ main (int argc, char **argv)
   }
   if (optind != argc)
     usage ();
-  if (sym == &sym_ascii) {
-       /*
-        * If the locale's charset is UTF-8, automatically
-        * use the UTF-8 symbols
-        */
-       if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
-               sym = &sym_utf;
-  }
   read_proc ();
   for (current = find_proc (highlight); current; current = current->parent)
     current->highlight = 1;