diff --git a/backport-0001-pstree-do-not-crash-on-missing-proc-xxxx-directory.patch b/backport-0001-pstree-do-not-crash-on-missing-proc-xxxx-directory.patch deleted file mode 100644 index 3715a0c..0000000 --- a/backport-0001-pstree-do-not-crash-on-missing-proc-xxxx-directory.patch +++ /dev/null @@ -1,32 +0,0 @@ -From d21bee476432e0d0442662fa7899d4dd4897e097 Mon Sep 17 00:00:00 2001 -From: Piotr Praszmo -Date: Wed, 23 Oct 2019 14:11:01 +0200 -Subject: [PATCH 46/65] pstree: do not crash on missing /proc/xxxx directory - -This can happen when process ends while pstree is running. -Ignore such processes. - -https://gitlab.com/psmisc/psmisc/-/commit/d21bee476432e0d0442662fa7899d4dd4897e097 ---- - src/pstree.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/src/pstree.c b/src/pstree.c -index 99881e9..3de0792 100644 ---- a/src/pstree.c -+++ b/src/pstree.c -@@ -1035,8 +1035,9 @@ static void read_proc(void) - } - #endif /*WITH_SELINUX */ - if (stat(path, &st) < 0) { -- perror(path); -- exit(1); -+ (void) fclose(file); -+ free(path); -+ continue; - } - size = fread(readbuf, 1, BUFSIZ, file); - if (ferror(file) == 0) { --- -2.22.0.windows.1 - diff --git a/backport-0002-pstree-additional-for-do-not-crash-on-missing-proces.patch b/backport-0002-pstree-additional-for-do-not-crash-on-missing-proces.patch deleted file mode 100644 index 8071e8b..0000000 --- a/backport-0002-pstree-additional-for-do-not-crash-on-missing-proces.patch +++ /dev/null @@ -1,33 +0,0 @@ -From b6c2b1288bd99f52d962301a2e41a0102d2a2d35 Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Fri, 15 Nov 2019 09:53:12 +1100 -Subject: [PATCH 47/65] pstree: additional for do not crash on missing - processes - -https://gitlab.com/psmisc/psmisc/-/commit/b6c2b1288bd99f52d962301a2e41a0102d2a2d35 - -This patch has been modified to fit euler os -Signed-off-by: chenmingmin ---- - src/pstree.c | 5 +++-- - 1 files changed, 3 insertions(+), 2 deletions(-) - -diff --git a/src/pstree.c b/src/pstree.c -index 3de0792..b05822e 100644 ---- a/src/pstree.c -+++ b/src/pstree.c -@@ -1030,8 +1030,9 @@ static void read_proc(void) - #ifdef WITH_SELINUX - if (selinux_enabled) - if (getpidcon(pid, &scontext) < 0) { -- perror(path); -- exit(1); -+ (void) fclose(file); -+ free(path); -+ continue; - } - #endif /*WITH_SELINUX */ - if (stat(path, &st) < 0) { --- -2.22.0.windows.1 - diff --git a/backport-0003-killall-minor-str-length-changes.patch b/backport-0003-killall-minor-str-length-changes.patch deleted file mode 100644 index 7f84b1f..0000000 --- a/backport-0003-killall-minor-str-length-changes.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 8df09a2792712a8852d637d07902896784721228 Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Mon, 2 Mar 2020 21:56:02 +1100 -Subject: [PATCH 09/20] killall: minor str length changes - -reworked some of the string handling to check for strchr and -strrchr return values. Removed check for unsigned to be negative, -that's not going to happen! - -References: - Coverity 288525 - -https://gitlab.com/psmisc/psmisc/-/commit/8df09a2792712a8852d637d07902896784721228 ---- - src/killall.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/src/killall.c b/src/killall.c -index 557fa51..524760b 100644 ---- a/src/killall.c -+++ b/src/killall.c -@@ -345,11 +345,12 @@ load_process_name_and_age(char *comm, double *process_age_sec, - return -1; - } - fclose(file); -- startcomm = strchr(buf, '(') + 1; -- endcomm = strrchr(startcomm, ')'); -+ if ( NULL == ( startcomm = strchr(buf, '('))) -+ return -1; -+ startcomm++; -+ if ( NULL == ( endcomm = strrchr(startcomm, ')'))) -+ return -1; - lencomm = endcomm - startcomm; -- if (lencomm < 0) -- lencomm = 0; - if (lencomm > COMM_LEN -1) - lencomm = COMM_LEN -1; - strncpy(comm, startcomm, lencomm); --- -2.22.0.windows.1 - diff --git a/backport-0004-pstree-minor-snprintf-fix.patch b/backport-0004-pstree-minor-snprintf-fix.patch deleted file mode 100644 index 370623e..0000000 --- a/backport-0004-pstree-minor-snprintf-fix.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 8fcc64ab2ca67bc46bdee8d7b50c6c6b9eb09318 Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Mon, 2 Mar 2020 22:00:25 +1100 -Subject: [PATCH 10/20] pstree: minor snprintf fix - -The referenced commit used size_t as a return value for -snprintf. - -Coverity found the negative check against size_t but the real -problem was using size_t in the first place as an error -returned by snprintf would never be detected. - -References: - commit 5e510d1c9ed8cb61f9c504076a7c4828624b8b07 - Coverity #288526 - -https://gitlab.com/psmisc/psmisc/-/commit/8fcc64ab2ca67bc46bdee8d7b50c6c6b9eb09318 ---- - src/pstree.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/pstree.c b/src/pstree.c -index c448539..da02564 100644 ---- a/src/pstree.c -+++ b/src/pstree.c -@@ -935,8 +935,7 @@ static char* get_threadname(const pid_t pid, const int tid, const char *comm) - FILE *file; - char *thread_comm, *endcomm, *threadname; - char *path = NULL; -- size_t len = 0; -- int nbytes; -+ int len, nbytes; - char readbuf[BUFSIZ + 1]; - - if (! (threadname = malloc(COMM_LEN + 2 + 1))) { --- -2.22.0.windows.1 - diff --git a/backport-0005-peekfd-Check-return-value-of-malloc.patch b/backport-0005-peekfd-Check-return-value-of-malloc.patch deleted file mode 100644 index 2dd7d03..0000000 --- a/backport-0005-peekfd-Check-return-value-of-malloc.patch +++ /dev/null @@ -1,32 +0,0 @@ -From edad7cd77c5b95db2f7fe4e3678e7444a1bcc399 Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Mon, 2 Mar 2020 22:08:27 +1100 -Subject: [PATCH 11/20] peekfd: Check return value of malloc - -If malloc returned null on lastbuf then we would have had a -derefencing NULL issue. - -References: - Coverity 46258 -https://gitlab.com/psmisc/psmisc/-/commit/edad7cd77c5b95db2f7fe4e3678e7444a1bcc399 ---- - src/peekfd.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/peekfd.c b/src/peekfd.c -index f41391a..360b2f7 100644 ---- a/src/peekfd.c -+++ b/src/peekfd.c -@@ -415,7 +415,8 @@ int main(int argc, char **argv) - if (remove_duplicates) { - if (lastbuf) - free(lastbuf); -- lastbuf = malloc(regs.REG_PARAM3); -+ if ( NULL == (lastbuf = malloc(regs.REG_PARAM3))) -+ perror("lastbuf malloc"); - last_buf_size = regs.REG_PARAM3; - } - --- -2.22.0.windows.1 - diff --git a/backport-0006-fuser-free-local-port-before-return.patch b/backport-0006-fuser-free-local-port-before-return.patch deleted file mode 100644 index a523c83..0000000 --- a/backport-0006-fuser-free-local-port-before-return.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 1ab3e9950f4c9cf749802a36e01249dde8e10c3b Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Mon, 2 Mar 2020 22:16:26 +1100 -Subject: [PATCH 12/20] fuser: free local port before return - -parse_inet allocated a string using strdup() but didn't always -release it. - -References: - Coverity #14401 -https://gitlab.com/psmisc/psmisc/-/commit/1ab3e9950f4c9cf749802a36e01249dde8e10c3b ---- - src/fuser.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/fuser.c b/src/fuser.c -index ac8244a..bbcbed2 100644 ---- a/src/fuser.c -+++ b/src/fuser.c -@@ -605,8 +605,10 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) - getaddrinfo(NULL, lcl_port_str, &hints, &res)) != 0) { - fprintf(stderr, _("Cannot resolve local port %s: %s\n"), - lcl_port_str, gai_strerror(errcode)); -+ free(lcl_port_str); - return -1; - } -+ free(lcl_port_str); - if (res == NULL) - return -1; - switch (res->ai_family) { -@@ -624,12 +626,10 @@ int parse_inet(struct names *this_name, struct ip_connections **ip_list) - fprintf(stderr, _("Unknown local port AF %d\n"), - res->ai_family); - freeaddrinfo(res); -- free(lcl_port_str); - return -1; - } - freeaddrinfo(res); - } -- free(lcl_port_str); - res = NULL; - if (rmt_addr_str == NULL && rmt_port_str == NULL) { - add_ip_conn(ip_list, protocol, this_name, ntohs(lcl_port), 0, --- -2.22.0.windows.1 - diff --git a/backport-0007-peekfd-exit-after-perror.patch b/backport-0007-peekfd-exit-after-perror.patch deleted file mode 100644 index 813a792..0000000 --- a/backport-0007-peekfd-exit-after-perror.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 02d3bdc1f283645e537b35e1a9cad34e40615277 Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Mon, 2 Mar 2020 22:27:20 +1100 -Subject: [PATCH 13/20] peekfd: exit() after perror() - -https://gitlab.com/psmisc/psmisc/-/commit/02d3bdc1f283645e537b35e1a9cad34e40615277 ---- - src/peekfd.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/peekfd.c b/src/peekfd.c -index 360b2f7..36dff04 100644 ---- a/src/peekfd.c -+++ b/src/peekfd.c -@@ -415,8 +415,10 @@ int main(int argc, char **argv) - if (remove_duplicates) { - if (lastbuf) - free(lastbuf); -- if ( NULL == (lastbuf = malloc(regs.REG_PARAM3))) -+ if ( NULL == (lastbuf = malloc(regs.REG_PARAM3))) { - perror("lastbuf malloc"); -+ exit(1); -+ } - last_buf_size = regs.REG_PARAM3; - } - --- -2.22.0.windows.1 - diff --git a/backport-0008-pstree-consecutive-NULs-in-cmdline-args-wrongly-pars.patch b/backport-0008-pstree-consecutive-NULs-in-cmdline-args-wrongly-pars.patch deleted file mode 100644 index d9c2666..0000000 --- a/backport-0008-pstree-consecutive-NULs-in-cmdline-args-wrongly-pars.patch +++ /dev/null @@ -1,31 +0,0 @@ -From c028ba11f90beecbd48d9a9f9ae8151622ea5fbc Mon Sep 17 00:00:00 2001 -From: Jan Rybar -Date: Wed, 29 Apr 2020 17:26:51 +0200 -Subject: [PATCH 16/20] pstree: consecutive NULs in cmdline args wrongly parsed - -https://gitlab.com/psmisc/psmisc/-/commit/c028ba11f90beecbd48d9a9f9ae8151622ea5fbc ---- - src/pstree.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/pstree.c b/src/pstree.c -index da02564..44e932c 100644 ---- a/src/pstree.c -+++ b/src/pstree.c -@@ -571,8 +571,12 @@ static void set_args(PROC * this, const char *args, int size) - } - this->argc = 0; - for (i = 0; i < size - 1; i++) -- if (!args[i]) -+ if (!args[i]) { - this->argc++; -+ /* now skip consecutive NUL */ -+ while(!args[i] && (i < size -1 )) -+ i++; -+ } - if (!this->argc) - return; - if (!(this->argv = malloc(sizeof(char *) * this->argc))) { --- -2.22.0.windows.1 - diff --git a/backport-0009-fuser-Less-confused-about-duplicate-dev_id.patch b/backport-0009-fuser-Less-confused-about-duplicate-dev_id.patch deleted file mode 100644 index 3c0777b..0000000 --- a/backport-0009-fuser-Less-confused-about-duplicate-dev_id.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 5c979b38253d187a8ecb8e52a0878b8bb668894f Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Fri, 22 May 2020 16:21:10 +1000 -Subject: [PATCH 17/20] fuser: Less confused about duplicate dev_id - -NFS mounts from the same server have the same device ID. This means -using the -m option a process using one of those mounts will be -"found" in all of the others too. - -lsof doesn't have this confusion as it checks the real path against -the mount point and only matches if they start the same. - -I think it would be confused with double stacked NFS shares such -as /nfs/SHARE1/blah/SHARE2 with the open file in SHARE2 but -there are limits. - -References: - psmisc/psmisc#10 - -https://gitlab.com/psmisc/psmisc/-/commit/5c979b38253d187a8ecb8e52a0878b8bb668894f -This patch has been modified to fit euler os -Signed-off-by: chenmingmin ---- - src/fuser.c | 22 ++++++++++++++++++++-- - src/fuser.h | 2 +- - 3 files changed, 21 insertions(+), 3 deletions(-) -diff --git a/src/fuser.c b/src/fuser.c -index bbcbed2..70da121 100644 ---- a/src/fuser.c -+++ b/src/fuser.c -@@ -56,6 +56,10 @@ - #define MAXSYMLINKS SYMLINK_MAX - #endif - -+#ifdef ENABLE_NLS -+#include -+#endif -+ - #include "fuser.h" - #include "signals.h" - #include "i18n.h" -@@ -64,6 +68,10 @@ - - //#define DEBUG 1 - -+#ifndef PATH_MAX -+#define PATH_MAX 4096 -+#endif /* PATH_MAX */ -+ - #define NAME_FIELD 20 /* space reserved for file name */ - /* Function defines */ - static void add_matched_proc(struct names *name_list, const pid_t pid, -@@ -1531,12 +1539,12 @@ print_matches(struct names *names_head, const opt_type opts, - - static struct stat *get_pidstat(const pid_t pid, const char *filename) - { -- char pathname[256]; -+ char pathname[PATH_MAX]; - struct stat *st; - - if ((st = (struct stat *)malloc(sizeof(struct stat))) == NULL) - return NULL; -- snprintf(pathname, 256, "/proc/%d/%s", pid, filename); -+ snprintf(pathname, PATH_MAX-1, "/proc/%d/%s", pid, filename); - if (timeout(thestat, pathname, st, 5) != 0) { - free(st); - return NULL; -@@ -1558,6 +1566,7 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, - struct stat st, lst; - char *dirpath; - char filepath[PATH_MAX]; -+ char real_filepath[PATH_MAX]; - - if (asprintf(&dirpath, "/proc/%d/%s", pid, dirname) < 0) - return; -@@ -1596,6 +1605,15 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, - dev_tmp = dev_tmp->next) { - if (thedev != dev_tmp->device) - continue; -+ -+ /* check the paths match */ -+ if (readlink(filepath, real_filepath, PATH_MAX-1) < 0) { -+ if (strncmp(dev_tmp->name->filename, filepath, strlen(dev_tmp->name->filename)) != 0) -+ continue; -+ } else { -+ if (strncmp(dev_tmp->name->filename, real_filepath, strlen(dev_tmp->name->filename)) != 0) -+ continue; -+ } - if (access == ACCESS_FILE - && (lstat(filepath, &lst) == 0) - && (lst.st_mode & S_IWUSR)) { -diff --git a/src/fuser.h b/src/fuser.h -index 93020d5..4500ec5 100644 ---- a/src/fuser.h -+++ b/src/fuser.h -@@ -40,7 +40,7 @@ struct procs { - struct names { - char *filename; - unsigned char name_space; -- struct stat st; -+ struct stat st; - struct procs *matched_procs; - struct names *next; - }; --- -2.22.0.windows.1 - diff --git a/backport-0010-fuser-Check-pathname-only-on-non-block-devices.patch b/backport-0010-fuser-Check-pathname-only-on-non-block-devices.patch deleted file mode 100644 index e8bbbba..0000000 --- a/backport-0010-fuser-Check-pathname-only-on-non-block-devices.patch +++ /dev/null @@ -1,56 +0,0 @@ -From b4566f854f29cad3d2249abcb7e472f5d3fbf169 Mon Sep 17 00:00:00 2001 -From: Craig Small -Date: Tue, 27 Oct 2020 21:59:25 +1100 -Subject: [PATCH] fuser: Check pathname only on non-block devices - -The referenced commit we would check the pathname to -ensure it matched our target. This worked fine for -real files. However for block devices it would fail -because "/dev/sda1" doesn't match "/mnt/myfile". - -We only check the pathname if the thing we are matching -against is not a block file. - -Thanks to @MarsChan for the report and also the suggested -fix! - -References: - commit 5c979b38253d187a8ecb8e52a0878b8bb668894f - psmisc/psmisc#31 - -Signed-off-by: Craig Small ---- - ChangeLog | 1 + - src/fuser.c | 16 +++++++++------- - 1 files changed, 9 insertions(+), 7 deletions(-) - -diff --git a/src/fuser.c b/src/fuser.c -index 70da121..03e6237 100644 ---- a/src/fuser.c -+++ b/src/fuser.c -@@ -1606,13 +1606,15 @@ check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, - if (thedev != dev_tmp->device) - continue; - -- /* check the paths match */ -- if (readlink(filepath, real_filepath, PATH_MAX-1) < 0) { -- if (strncmp(dev_tmp->name->filename, filepath, strlen(dev_tmp->name->filename)) != 0) -- continue; -- } else { -- if (strncmp(dev_tmp->name->filename, real_filepath, strlen(dev_tmp->name->filename)) != 0) -- continue; -+ /* check the paths match if it is not a block device */ -+ if (! S_ISBLK(dev_tmp->name->st.st_mode)) { -+ if (readlink(filepath, real_filepath, PATH_MAX-1) < 0) { -+ if (strncmp(dev_tmp->name->filename, filepath, strlen(dev_tmp->name->filename)) != 0) -+ continue; -+ } else { -+ if (strncmp(dev_tmp->name->filename, real_filepath, strlen(dev_tmp->name->filename)) != 0) -+ continue; -+ } - } - if (access == ACCESS_FILE - && (lstat(filepath, &lst) == 0) --- -1.8.3.1 - diff --git a/bugfix-fix-pstree-coredump-due-pid-reuse.patch b/bugfix-fix-pstree-coredump-due-pid-reuse.patch deleted file mode 100644 index 53252aa..0000000 --- a/bugfix-fix-pstree-coredump-due-pid-reuse.patch +++ /dev/null @@ -1,198 +0,0 @@ -From 9eec9fc3cf7960157c42105343492a07f1039fce Mon Sep 17 00:00:00 2001 -From: chenmingmin -Date: Fri, 17 Apr 2020 08:52:38 -0400 -Subject: [PATCH] pstree scans /proc directory to construct tree of all - processes. In scanning, if a pid or tid is already added to ps tree, and then - exists, and it is reused by another process or thread, there will be a loop - in ps tree, and will cause coredump in tree_equal function. An example step - is as below. -1. process A added to ps tree -2. process B added to ps tree as a child of Author -3. B exists and its pid is reused by process C(with same pid as B) -4. A exists and its pid is reused by process D(with same pid as A) as a - child of process C -5. hence, A(pid1)->B(pid2)->C(pid2)->D(pid1)->B(pid)->... loop is constructed -This patch fix this problem by not adding processes with pid reused to ps tree. - ---- - src/pstree.c | 112 ++++++++++++++++++++++++++++++++------------------- - 1 file changed, 71 insertions(+), 41 deletions(-) - -diff --git a/src/pstree.c b/src/pstree.c -index 99881e9..4212c8b 100644 ---- a/src/pstree.c -+++ b/src/pstree.c -@@ -127,6 +127,8 @@ typedef struct _proc { - #define PFLAG_HILIGHT 0x01 - #define PFLAG_THREAD 0x02 - -+#define ISTHREAD(proc) ((proc)->flags & ~PFLAG_THREAD) -+ - typedef struct _child { - PROC *child; - struct _child *next; -@@ -615,16 +617,44 @@ rename_proc(PROC *this, const char *comm, uid_t uid) - } - } - --static void -+static int has_proc_loop(const PROC *parent, const PROC *child) { -+ int ret = 0; -+ const PROC *raw_parent = parent; -+ if(child != NULL) { -+ while(parent != NULL) { -+ if(parent == child) { -+ ret = 1; -+ break ; -+ } -+ parent = parent->parent; -+ if(parent == raw_parent) -+ break ; -+ } -+ } -+ return ret; -+} -+ -+static int - add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid, - const char *args, int size, char isthread, security_context_t scontext, - double process_age_sec) - { - PROC *this, *parent; -+ if (!(parent = find_proc(ppid))) { -+ parent = new_proc("?", ppid, 0, scontext); -+ } - - if (!(this = find_proc(pid))) - this = new_proc(comm, pid, uid, scontext); - else { -+ if(strcmp(this->comm, "?") != 0 || has_proc_loop(parent, this)) { -+ /*when comm is not ?, then it is not a placeholder process, and there -+ * comes the scenario of pid/tid reuse. -+ * or if it is a placeholder, but there contains a proc loop, -+ * it will not be added to ps tree. -+ */ -+ return -1; -+ } - rename_proc(this, comm, uid); - } - if (args) -@@ -635,13 +665,13 @@ add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid, - this->age = process_age_sec; - if (isthread) - this->flags |= PFLAG_THREAD; -- if (!(parent = find_proc(ppid))) { -- parent = new_proc("?", ppid, 0, scontext); -- } -- if (pid != 0) { -+ -+ if (pid != 0 && !ISTHREAD(parent)) { -+ /*thread can not have any children. this can happen when a tid is reused as a pid*/ - add_child(parent, this); - this->parent = parent; - } -+ return 0; - } - - -@@ -993,7 +1023,7 @@ static void read_proc(void) - char readbuf[BUFSIZ + 1]; - char *tmpptr, *endptr; - pid_t pid, ppid, pgid; -- int fd, size; -+ int fd, size,ret; - int empty; - security_context_t scontext = NULL; - unsigned long long proc_stt_jf = 0; -@@ -1057,44 +1087,14 @@ static void read_proc(void) - char *taskpath; - int thread; - -- process_age_sec = process_age(proc_stt_jf); -- /* handle process threads */ -- if (! hide_threads) { -- if (! (taskpath = malloc(strlen(path) + 10))) -- exit(2); -- sprintf(taskpath, "%s/task", path); -- -- if ((taskdir = opendir(taskpath)) != 0) { -- /* if we have this dir, we're on 2.6 */ -- while ((dt = readdir(taskdir)) != NULL) { -- if ((thread = atoi(dt->d_name)) != 0) { -- if (thread != pid) { -- char *threadname; -- threadname = get_threadname(pid, thread, comm); -- if (print_args) -- add_proc(threadname, thread, pid, pgid, st.st_uid, -- threadname, strlen (threadname) + 1, 1,scontext, -- process_age_sec); -- else -- add_proc(threadname, thread, pid, pgid, st.st_uid, -- NULL, 0, 1, scontext, -- process_age_sec); -- free(threadname); -- } -- } -- } -- (void) closedir(taskdir); -- } -- free(taskpath); -- } -- -+ char cmdline[128]; - /* handle process */ - if (!print_args) -- add_proc(comm, pid, ppid, pgid, st.st_uid, NULL, 0, 0, scontext, -+ ret = add_proc(comm, pid, ppid, pgid, st.st_uid, NULL, 0, 0, scontext, - process_age_sec); - else { -- sprintf(path, "%s/%d/cmdline", PROC_BASE, pid); -- if ((fd = open(path, O_RDONLY)) < 0) { -+ sprintf(cmdline, "%s/%d/cmdline", PROC_BASE, pid); -+ if ((fd = open(cmdline, O_RDONLY)) < 0) { - /* If this fails then the process is gone. If a PID - * was specified on the command-line then we might - * not even be interested in the current process. -@@ -1119,9 +1119,39 @@ static void read_proc(void) - size--; - if (size) - buffer[size++] = 0; -- add_proc(comm, pid, ppid, pgid, st.st_uid, -+ ret = add_proc(comm, pid, ppid, pgid, st.st_uid, - buffer, size, 0, scontext, process_age_sec); - } -+ -+ if (ret >= 0) {/*do not add tids to ps tree when its parent process reuses pid/tid*/ -+ /* handle process threads */ -+ if (!hide_threads) { -+ if (! (taskpath = malloc(strlen(path) + 10))) -+ exit(2); -+ sprintf(taskpath, "%s/task", path); -+ -+ if ((taskdir = opendir(taskpath)) != 0) { -+ /* if we have this dir, we're on 2.6 */ -+ while ((dt = readdir(taskdir)) != NULL) { -+ if ((thread = atoi(dt->d_name)) != 0) { -+ if (thread != pid) { -+ char *threadname; -+ threadname = get_threadname(pid, thread, comm); -+ if (print_args) -+ add_proc(threadname, thread, pid, pgid, st.st_uid, -+ threadname, strlen (threadname) + 1, 1,scontext,process_age_sec); -+ else -+ add_proc(threadname, thread, pid, pgid, st.st_uid, -+ NULL, 0, 1, scontext,process_age_sec); -+ free(threadname); -+ } -+ } -+ } -+ (void) closedir(taskdir); -+ } -+ free(taskpath); -+ } -+ } - } - } - } --- -2.19.1 diff --git a/psmisc-23.3.tar.xz b/psmisc-23.3.tar.xz deleted file mode 100644 index b34748b..0000000 Binary files a/psmisc-23.3.tar.xz and /dev/null differ diff --git a/psmisc-23.4.tar.xz b/psmisc-23.4.tar.xz new file mode 100644 index 0000000..d1b51bd Binary files /dev/null and b/psmisc-23.4.tar.xz differ diff --git a/psmisc.spec b/psmisc.spec index 21c55e7..8ac5c16 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -1,25 +1,12 @@ Name: psmisc -Version: 23.3 -Release: 3 +Version: 23.4 +Release: 1 Summary: Utilities for managing processes on your system License: GPLv2+ URL: https://gitlab.com/psmisc/psmisc Source0: https://sourceforge.net/projects/%{name}/files/%{name}/%{name}-%{version}.tar.xz BuildRequires: libselinux-devel gettext ncurses-devel autoconf automake gcc -Patch0000: backport-0001-pstree-do-not-crash-on-missing-proc-xxxx-directory.patch -Patch0001: backport-0002-pstree-additional-for-do-not-crash-on-missing-proces.patch -Patch0002: backport-0003-killall-minor-str-length-changes.patch -Patch0003: backport-0004-pstree-minor-snprintf-fix.patch -Patch0004: backport-0005-peekfd-Check-return-value-of-malloc.patch -Patch0005: backport-0006-fuser-free-local-port-before-return.patch -Patch0006: backport-0007-peekfd-exit-after-perror.patch -Patch0007: backport-0008-pstree-consecutive-NULs-in-cmdline-args-wrongly-pars.patch -Patch0008: backport-0009-fuser-Less-confused-about-duplicate-dev_id.patch -Patch0009: backport-0010-fuser-Check-pathname-only-on-non-block-devices.patch - -Patch9001: bugfix-fix-pstree-coredump-due-pid-reuse.patch - %description This PSmisc package is a set of some small useful utilities that use the proc filesystem. We're not about changing the world, but providing the system @@ -36,7 +23,7 @@ administrator with some help in common tasks. %make_install mkdir -p $RPM_BUILD_ROOT%{_sbindir} mv $RPM_BUILD_ROOT%{_bindir}/fuser $RPM_BUILD_ROOT%{_sbindir} -%find_lang %name +%find_lang %name --all-name --with-man %files -f %{name}.lang %{_sbindir}/fuser @@ -46,6 +33,9 @@ mv $RPM_BUILD_ROOT%{_bindir}/fuser $RPM_BUILD_ROOT%{_sbindir} %doc AUTHORS ChangeLog README %changelog +* Thu Dec 2 2021 zhouwenpei - 23.4-1 +- upgrade to 23.4 + * Fri Jul 30 2021 chenyanpanHW - 23.3-3 - DESC: delete -Sgit from %autosetup, and delete BuildRequires git