head 1.7; access; symbols pkgsrc-2026Q1:1.7.0.44 pkgsrc-2026Q1-base:1.7 pkgsrc-2025Q4:1.7.0.42 pkgsrc-2025Q4-base:1.7 pkgsrc-2025Q3:1.7.0.40 pkgsrc-2025Q3-base:1.7 pkgsrc-2025Q2:1.7.0.38 pkgsrc-2025Q2-base:1.7 pkgsrc-2025Q1:1.7.0.36 pkgsrc-2025Q1-base:1.7 pkgsrc-2024Q4:1.7.0.34 pkgsrc-2024Q4-base:1.7 pkgsrc-2024Q3:1.7.0.32 pkgsrc-2024Q3-base:1.7 pkgsrc-2024Q2:1.7.0.30 pkgsrc-2024Q2-base:1.7 pkgsrc-2024Q1:1.7.0.28 pkgsrc-2024Q1-base:1.7 pkgsrc-2023Q4:1.7.0.26 pkgsrc-2023Q4-base:1.7 pkgsrc-2023Q3:1.7.0.24 pkgsrc-2023Q3-base:1.7 pkgsrc-2023Q2:1.7.0.22 pkgsrc-2023Q2-base:1.7 pkgsrc-2023Q1:1.7.0.20 pkgsrc-2023Q1-base:1.7 pkgsrc-2022Q4:1.7.0.18 pkgsrc-2022Q4-base:1.7 pkgsrc-2022Q3:1.7.0.16 pkgsrc-2022Q3-base:1.7 pkgsrc-2022Q2:1.7.0.14 pkgsrc-2022Q2-base:1.7 pkgsrc-2022Q1:1.7.0.12 pkgsrc-2022Q1-base:1.7 pkgsrc-2021Q4:1.7.0.10 pkgsrc-2021Q4-base:1.7 pkgsrc-2021Q3:1.7.0.8 pkgsrc-2021Q3-base:1.7 pkgsrc-2021Q2:1.7.0.6 pkgsrc-2021Q2-base:1.7 pkgsrc-2021Q1:1.7.0.4 pkgsrc-2021Q1-base:1.7 pkgsrc-2020Q4:1.7.0.2 pkgsrc-2020Q4-base:1.7 pkgsrc-2020Q3:1.6.0.50 pkgsrc-2020Q3-base:1.6 pkgsrc-2020Q2:1.6.0.46 pkgsrc-2020Q2-base:1.6 pkgsrc-2020Q1:1.6.0.26 pkgsrc-2020Q1-base:1.6 pkgsrc-2019Q4:1.6.0.48 pkgsrc-2019Q4-base:1.6 pkgsrc-2019Q3:1.6.0.44 pkgsrc-2019Q3-base:1.6 pkgsrc-2019Q2:1.6.0.42 pkgsrc-2019Q2-base:1.6 pkgsrc-2019Q1:1.6.0.40 pkgsrc-2019Q1-base:1.6 pkgsrc-2018Q4:1.6.0.38 pkgsrc-2018Q4-base:1.6 pkgsrc-2018Q3:1.6.0.36 pkgsrc-2018Q3-base:1.6 pkgsrc-2018Q2:1.6.0.34 pkgsrc-2018Q2-base:1.6 pkgsrc-2018Q1:1.6.0.32 pkgsrc-2018Q1-base:1.6 pkgsrc-2017Q4:1.6.0.30 pkgsrc-2017Q4-base:1.6 pkgsrc-2017Q3:1.6.0.28 pkgsrc-2017Q3-base:1.6 pkgsrc-2017Q2:1.6.0.24 pkgsrc-2017Q2-base:1.6 pkgsrc-2017Q1:1.6.0.22 pkgsrc-2017Q1-base:1.6 pkgsrc-2016Q4:1.6.0.20 pkgsrc-2016Q4-base:1.6 pkgsrc-2016Q3:1.6.0.18 pkgsrc-2016Q3-base:1.6 pkgsrc-2016Q2:1.6.0.16 pkgsrc-2016Q2-base:1.6 pkgsrc-2016Q1:1.6.0.14 pkgsrc-2016Q1-base:1.6 pkgsrc-2015Q4:1.6.0.12 pkgsrc-2015Q4-base:1.6 pkgsrc-2015Q3:1.6.0.10 pkgsrc-2015Q3-base:1.6 pkgsrc-2015Q2:1.6.0.8 pkgsrc-2015Q2-base:1.6 pkgsrc-2015Q1:1.6.0.6 pkgsrc-2015Q1-base:1.6 pkgsrc-2014Q4:1.6.0.4 pkgsrc-2014Q4-base:1.6 pkgsrc-2014Q3:1.6.0.2 pkgsrc-2014Q3-base:1.6 pkgsrc-2014Q2:1.5.0.6 pkgsrc-2014Q2-base:1.5 pkgsrc-2014Q1:1.5.0.4 pkgsrc-2014Q1-base:1.5 pkgsrc-2013Q4:1.5.0.2 pkgsrc-2013Q4-base:1.5 pkgsrc-2013Q3:1.4.0.92 pkgsrc-2013Q3-base:1.4 pkgsrc-2013Q2:1.4.0.90 pkgsrc-2013Q2-base:1.4 pkgsrc-2013Q1:1.4.0.88 pkgsrc-2013Q1-base:1.4 pkgsrc-2012Q4:1.4.0.86 pkgsrc-2012Q4-base:1.4 pkgsrc-2012Q3:1.4.0.84 pkgsrc-2012Q3-base:1.4 pkgsrc-2012Q2:1.4.0.82 pkgsrc-2012Q2-base:1.4 pkgsrc-2012Q1:1.4.0.80 pkgsrc-2012Q1-base:1.4 pkgsrc-2011Q4:1.4.0.78 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q3:1.4.0.76 pkgsrc-2011Q3-base:1.4 pkgsrc-2011Q2:1.4.0.74 pkgsrc-2011Q2-base:1.4 pkgsrc-2011Q1:1.4.0.72 pkgsrc-2011Q1-base:1.4 pkgsrc-2010Q4:1.4.0.70 pkgsrc-2010Q4-base:1.4 pkgsrc-2010Q3:1.4.0.68 pkgsrc-2010Q3-base:1.4 pkgsrc-2010Q2:1.4.0.66 pkgsrc-2010Q2-base:1.4 pkgsrc-2010Q1:1.4.0.64 pkgsrc-2010Q1-base:1.4 pkgsrc-2009Q4:1.4.0.62 pkgsrc-2009Q4-base:1.4 pkgsrc-2009Q3:1.4.0.60 pkgsrc-2009Q3-base:1.4 pkgsrc-2009Q2:1.4.0.58 pkgsrc-2009Q2-base:1.4 pkgsrc-2009Q1:1.4.0.56 pkgsrc-2009Q1-base:1.4 pkgsrc-2008Q4:1.4.0.54 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.52 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.50 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.48 pkgsrc-2008Q2-base:1.4 cwrapper:1.4.0.46 pkgsrc-2008Q1:1.4.0.44 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.42 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.40 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.38 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.36 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.34 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.32 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.30 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.28 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.26 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.24 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.22 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.4.0.20 pkgsrc-2005Q1-base:1.4 pkgsrc-2004Q4:1.4.0.18 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.16 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.4.0.14 pkgsrc-2004Q2-base:1.4 pkgsrc-2004Q1:1.4.0.12 pkgsrc-2004Q1-base:1.4 pkgsrc-2003Q4:1.4.0.10 pkgsrc-2003Q4-base:1.4 netbsd-1-6-1:1.4.0.6 netbsd-1-6-1-base:1.4 netbsd-1-6:1.4.0.8 netbsd-1-6-RELEASE-base:1.4 pkgviews:1.4.0.4 pkgviews-base:1.4 buildlink2:1.4.0.2 buildlink2-base:1.4 netbsd-1-5-PATCH003:1.4 netbsd-1-5-PATCH001:1.4 netbsd-1-4-PATCH002:1.2 comdex-fall-1999:1.2 netbsd-1-4-PATCH001:1.2 netbsd-1-4-RELEASE:1.2 netbsd-1-3-PATCH003:1.2; locks; strict; comment @# @; 1.7 date 2020.10.06.00.19.05; author mcf; state Exp; branches; next 1.6; commitid nwp21o1XDCMo3MqC; 1.6 date 2014.09.23.22.18.21; author jperkin; state Exp; branches; next 1.5; commitid I1oaBW2UDPz5jwRx; 1.5 date 2013.12.13.09.58.58; author jperkin; state Exp; branches; next 1.4; commitid NVvEWRSTsYRplXgx; 1.4 date 2001.04.24.16.59.35; author jlam; state Exp; branches; next 1.3; 1.3 date 2000.03.17.15.54.53; author jlam; state dead; branches; next 1.2; 1.2 date 98.08.07.11.14.08; author agc; state Exp; branches; next 1.1; 1.1 date 98.07.20.10.25.53; author frueauf; state Exp; branches; next ; desc @@ 1.7 log @psmisc: fix sscanf usage bug under musl libc C99 says that the %15c conversion specifier matches *exactly* 15 characters, so if the process name is shorter than 15 characters, it is not matched and 0 is returned. Some implementations (such as glibc) return a match, even with fewer characters than the field width, but this cannot be assumed. Instead, use %15[^)], as in upstream commit [0], which matches a non-empty sequence of characters other than ')'. [0] https://gitlab.com/psmisc/psmisc/-/commit/ca2b176889729a7347bd95b832b9a5bb39fec229 @ text @$NetBSD: patch-af,v 1.6 2014/09/23 22:18:21 jperkin Exp $ Need limits.h for PATH_MAX Fix sscanf usage bug on musl libc and uclibc (upstream commit https://gitlab.com/psmisc/psmisc/-/commit/ca2b176889729a7347bd95b832b9a5bb39fec229) --- src/pstree.c.orig 2000-12-18 05:59:23.000000000 +0000 +++ src/pstree.c @@@@ -15,19 +15,22 @@@@ #include #include #include +#include #include +#ifdef HAVE_TERMCAP_H #include +#endif #include #include #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 +306,7 @@@@ dump_tree (PROC * current, int level, in 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 +331,8 @@@@ dump_tree (PROC * current, int level, in 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 +371,8 @@@@ dump_tree (PROC * current, int level, in } 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 +510,7 @@@@ read_proc (void) 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,16 +519,19 @@@@ read_proc (void) 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) { memset(comm, '\0', COMM_LEN+1); tmpptr = strrchr(readbuf, ')'); /* find last ) */ - *tmpptr = '\0'; /* We now have readbuf with pid and cmd, and tmpptr+2 * with the rest */ /*printf("readbuf: %s\n", readbuf);*/ - if (sscanf(readbuf, "%*d (%15c", comm) == 1) + if (sscanf(readbuf, "%*d (%15[^)]", comm) == 1) { /*printf("tmpptr: %s\n", tmpptr+2);*/ if (sscanf(tmpptr+2, "%*c %d", &ppid) == 1) @@@@ -532,11 +541,12 @@@@ read_proc (void) (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 +651,11 @@@@ main (int argc, char **argv) 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; @ 1.6 log @Fix build on systems which lack BSD termcap. @ text @d1 1 a1 1 $NetBSD: patch-af,v 1.5 2013/12/13 09:58:58 jperkin Exp $ d5 3 d71 1 a71 1 @@@@ -513,6 +519,10 @@@@ read_proc (void) d82 12 a93 1 @@@@ -532,11 +542,12 @@@@ read_proc (void) d107 1 a107 1 @@@@ -641,7 +652,11 @@@@ main (int argc, char **argv) @ 1.5 log @Need limits.h for PATH_MAX on SunOS. @ text @d1 1 a1 1 $NetBSD: patch-af,v 1.4 2001/04/24 16:59:35 jlam Exp $ d7 1 a7 1 @@@@ -15,6 +15,7 @@@@ d13 1 d15 1 d17 1 a17 1 @@@@ -22,12 +23,12 @@@@ d31 1 a31 1 @@@@ -303,6 +304,7 @@@@ dump_tree (PROC * current, int level, in d39 1 a39 1 @@@@ -327,7 +329,8 @@@@ dump_tree (PROC * current, int level, in d49 1 a49 1 @@@@ -366,7 +369,8 @@@@ dump_tree (PROC * current, int level, in d59 1 a59 1 @@@@ -504,7 +508,7 @@@@ read_proc (void) d68 1 a68 1 @@@@ -513,6 +517,10 @@@@ read_proc (void) d79 1 a79 1 @@@@ -532,11 +540,12 @@@@ read_proc (void) d93 1 a93 1 @@@@ -641,7 +650,11 @@@@ main (int argc, char **argv) @ 1.4 log @Update psmisc to 20.1. Changes from version 19: - command line - put back in. - got rid of annoying "sending signal #" debug message - updated killall.1 - updated killall usage - verbose now tells you what signal it is killing with. - New maintainer - Uses automake/autoconf to determine things - License changed to GPL - signames.h generated better (suggested by Grant Erickson) - uses getopt() for better command line stuff - makes less assumptions about process name, closes Debian Bug #53337 - Doesn't use losetup for loop devices in fuser. - Better selection of process name (thanks to David desJardins) @ text @d1 1 a1 1 $NetBSD$ d3 3 a5 1 --- src/pstree.c.orig Mon Dec 18 00:59:23 2000 d7 9 a15 1 @@@@ -22,12 +22,12 @@@@ d29 1 a29 1 @@@@ -303,6 +303,7 @@@@ d37 1 a37 1 @@@@ -327,7 +328,8 @@@@ d47 1 a47 1 @@@@ -366,7 +368,8 @@@@ d57 1 a57 1 @@@@ -504,7 +507,7 @@@@ d66 1 a66 1 @@@@ -513,6 +516,10 @@@@ d77 1 a77 1 @@@@ -532,11 +539,12 @@@@ d91 1 a91 1 @@@@ -641,7 +649,11 @@@@ @ 1.3 log @Updated psmisc to version 19. Changes from version 17: - supports /proc/cmdline on NetBSD - killall: new option -g to kill process group instead of process - pidof: new option -g to show PGID instead of PID (by Florian La Roche) - pstree: new option -H to highlight process specified by PID @ text @d1 1 a1 1 $NetBSD: patch-af,v 1.2 1998/08/07 11:14:08 agc Exp $ d3 90 a92 10 --- pstree.1.orig Sun Apr 7 15:57:44 1996 +++ pstree.1 Sun Jul 19 23:51:52 1998 @@@@ -78,4 +78,7 @@@@ Werner Almesberger .SH "SEE ALSO" ps(1), top(1) +.SH BUGS +The \fB\-a\fP option does nothing of any use under NetBSD due to deficiencies +in the BSD version of /proc. .\"{{{}}} @ 1.2 log @Add NetBSD RCS Ids. @ text @d1 1 a1 1 $NetBSD$ @ 1.1 log @Initial addition of psmisc-17, some miscellaneous proc FS tools: killall, pidof, and pstree. Closes pr 5801 by Ben Harris. @ text @d1 2 @