From: Craig Small Date: Tue, 16 Dec 2008 10:15:16 +0000 (+0000) Subject: * Patch from Arnaud Giersch to fix udp ports in fuser Debian #502208 X-Git-Tag: v22.11~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d503338370506a2de4f3d3fb54266689b12a22a;p=psmisc * Patch from Arnaud Giersch to fix udp ports in fuser Debian #502208 * pstree man page mentions -Z may not be available Debian #478327 * pstree handles UTF-8 lengths much better Debian #413503 * killall says no process found when process not found Debian #500097 * pstree makes a bigger buffer for -al flags Debian #352603 --- diff --git a/ChangeLog b/ChangeLog index 15db24b..e1dc117 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ Changes in ?? = ============= +2008-12-16 Craig Small + * Patch from Arnaud Giersch to fix udp ports in fuser Debian #502208 + * pstree man page mentions -Z may not be available Debian #478327 + * pstree handles UTF-8 lengths much better Debian #413503 + * killall says no process found when process not found Debian #500097 + * pstree makes a bigger buffer for -al flags Debian #352603 + 2008-12-05 Craig Small * Dynamically reallocate buffer for fuser patch from Don Armstrong diff --git a/doc/pstree.1 b/doc/pstree.1 index c7b122c..512b0aa 100644 --- a/doc/pstree.1 +++ b/doc/pstree.1 @@ -92,7 +92,8 @@ with \fBecho \-e '\\033%@'\fP .IP \fB\-V\fP Display version information. .IP \fB\-Z\fP -(SELinux) Show security context for each process. +(SELinux) Show security context for each process. This flag will only work if +pstree is compilied with SELinux support. .SH FILES .nf /proc location of the proc file system diff --git a/src/fuser.c b/src/fuser.c index b1fe21a..9edc0ea 100644 --- a/src/fuser.c +++ b/src/fuser.c @@ -4,7 +4,7 @@ * Based on fuser.c Copyright (C) 1993-2005 Werner Almesberger and Craig Small * * Completely re-written - * Copyright (C) 2005-2007 Craig Small + * Copyright (C) 2005-2008 Craig Small * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -822,9 +822,9 @@ int main(int argc, char *argv[]) case NAMESPACE_UDP: asprintf(&(this_name->filename), "%s/udp", argv[optc]); #ifdef WITH_IPV6 - parse_inet(this_name, ipv4_only, ipv6_only, &tcp_connection_list, &tcp6_connection_list); + parse_inet(this_name, ipv4_only, ipv6_only, &udp_connection_list, &udp6_connection_list); #else - parse_inet(this_name, &tcp_connection_list); + parse_inet(this_name, &udp_connection_list); #endif break; default: /* FILE */ diff --git a/src/killall.c b/src/killall.c index e9a47b7..1e5b92a 100644 --- a/src/killall.c +++ b/src/killall.c @@ -456,7 +456,7 @@ kill_all (int signal, int names, char **namelist, struct passwd *pwent) if (!quiet && !pidof) for (i = 0; i < names; i++) if (!(found & (1 << i))) - fprintf (stderr, _("%s: no process killed\n"), namelist[i]); + fprintf (stderr, _("%s: no process found\n"), namelist[i]); if (pidof) putchar ('\n'); if (names) diff --git a/src/pstree.c b/src/pstree.c index f6855ba..8b01712 100644 --- a/src/pstree.c +++ b/src/pstree.c @@ -2,7 +2,7 @@ * pstree.c - display process tree * * Copyright (C) 1993-2002 Werner Almesberger - * Copyright (C) 2002-2005 Craig Small + * Copyright (C) 2002-2008 Craig Small * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -136,6 +136,7 @@ static int output_width = 132; static int cur_x = 1; static char last_char = 0; static int dumped = 0; /* used by dump_by_user */ +static int charlen = 0; /* length of character */ /* * Allocates additional buffer space for width and more as needed. @@ -183,19 +184,31 @@ static void free_buffers() { static void out_char (char c) { - cur_x += (c & 0xc0) != 0x80; /* only count first UTF-8 char */ - if (cur_x <= output_width || !trunc) - putchar (c); - if (cur_x == output_width + 1 && trunc && ((c & 0xc0) != 0x80)) + if (charlen == 0) /* "new" character */ { - if (last_char || (c & 0x80)) - putchar ('+'); - else - { - last_char = c; - cur_x--; - return; - } + if ( (c & 0x80) == 0) + { + charlen = 1; /* ASCII */ + } else if ( (c & 0xe0) == 0xc0) /* 110.. 2 bytes */ + { + charlen = 2; + } else if ( (c & 0xf0) == 0xe0) /* 1110.. 3 bytes */ + { + charlen = 3; + } else if ( (c & 0xf8) == 0xf0) /* 11110.. 4 bytes */ + { + charlen = 4; + } else { + charlen = 1; + } + cur_x++; /* count first byte of whatever it is only */ + } + charlen--; + if (!trunc || cur_x <= output_width) + putchar (c); + else { + if (trunc && (cur_x == output_width + 1)) + putchar('+'); } } @@ -476,7 +489,7 @@ dump_tree (PROC * current, int level, int rep, int leaf, int last, if (current->highlight && (tmp = tgetstr ("me", NULL))) tputs (tmp, 1, putchar); if (print_args) - { + { for (i = 0; i < current->argc; i++) { if (i < current->argc-1) /* Space between words but not at the end of last */ @@ -499,7 +512,7 @@ dump_tree (PROC * current, int level, int rep, int leaf, int last, break; } } - } + } #ifdef WITH_SELINUX if ( show_scontext || print_args || ! current->children ) #else /*WITH_SELINUX*/ @@ -603,6 +616,7 @@ read_proc (void) struct stat st; char *path, *comm; char *buffer; + size_t buffer_size; char readbuf[BUFSIZ+1]; char *tmpptr; pid_t pid, ppid; @@ -613,9 +627,14 @@ read_proc (void) int selinux_enabled=is_selinux_enabled()>0; #endif /*WITH_SELINUX*/ + if (trunc) + buffer_size = output_width+1; + else + buffer_size = BUFSIZ+1; + if (!print_args) buffer = NULL; - else if (!(buffer = malloc ((size_t) (output_width + 1)))) + else if (!(buffer = malloc (buffer_size))) { perror ("malloc"); exit (1); @@ -724,7 +743,7 @@ read_proc (void) perror (path); exit (1); } - if ((size = read (fd, buffer, (size_t) output_width)) < 0) + if ((size = read (fd, buffer, buffer_size)) < 0) { perror (path); exit (1);