From: Craig Small Date: Sat, 24 Apr 2004 12:47:20 +0000 (+0000) Subject: -A flag for pstree X-Git-Tag: v22.11~159 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=437168b93f9176ce717782e051d930c66aeddbea;p=psmisc -A flag for pstree --- diff --git a/ChangeLog b/ChangeLog index 3e87c49..5833b16 100644 --- 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 diff --git a/autom4te.cache/requests b/autom4te.cache/requests index 504d659..6f79e10 100644 --- a/autom4te.cache/requests +++ b/autom4te.cache/requests @@ -17,19 +17,19 @@ { '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, @@ -48,17 +48,17 @@ '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, @@ -80,33 +80,33 @@ '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 diff --git a/doc/pstree.1 b/doc/pstree.1 index c9a8640..391fe35 100644 --- a/doc/pstree.1 +++ b/doc/pstree.1 @@ -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. diff --git a/src/pstree.c b/src/pstree.c index dcbce90..50fcff9 100644 --- a/src/pstree.c +++ b/src/pstree.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include #include @@ -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;