I think it is cleaner like this:


root@kibar:~/procps-3.3.16# diff -u ../orig/procps-3.3.16/pgrep.c pgrep.c

--- ../orig/procps-3.3.16/pgrep.c       2020-02-06 06:04:02.000000000 -0500

+++ pgrep.c     2021-02-02 12:24:49.000000000 -0500

@@ -494,10 +494,15 @@

        pid_t saved_pid = 0;                      /* for new/old support */

        int matches = 0;

        int size = 0;

+       long cmdlen, SC_ARG_MAX;

        regex_t *preg;

        pid_t myself = getpid();

        struct el *list = NULL;

-        long cmdlen = sysconf(_SC_ARG_MAX) * sizeof(char);

+       SC_ARG_MAX = sysconf(_SC_ARG_MAX);

+       if (SC_ARG_MAX == -1) // no limitations

+               cmdlen = 1000 * sizeof(char);

+       else

+               cmdlen = SC_ARG_MAX * sizeof(char);

        char *cmdline = xmalloc(cmdlen);

        char *cmdsearch = xmalloc(cmdlen);

        char *cmdoutput = xmalloc(cmdlen);

root@kibar:~/procps-3.3.16# 



Will try to send a bug report upstream... will give the link here when done.

Reply via email to