* 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>
{
'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
.RB [ \-n ]
.RB [ \-p ]
.RB [ \-u ]
-.RB [ \-G | \-U ]
+.RB [ \-A | \-G | \-U ]
.RB [ \fIpid\fB | \fIuser\fB]
.br
.B pstree
.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.
#include <getopt.h>
#include <pwd.h>
#include <dirent.h>
+#include <curses.h>
+#include <term.h>
#include <termios.h>
#include <termcap.h>
#include <langinfo.h>
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"));
const struct passwd *pw;
pid_t pid, highlight;
char termcap_area[1024];
+ char *termname;
int c;
char *tmpstr;
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':
user_change = 1;
break;
case 'U':
- if (sym != &sym_ascii)
- usage ();
sym = &sym_utf;
break;
case 'V':
}
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;