X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fprocesses.c;h=aa47f3328f86355ba020ab2730ce237503f9aa4e;hb=9faff71de9d74939223192766c93e1d18c2d1186;hp=dcdaaf291c92088aae58b5cb0d7cef8104ae8509;hpb=108c5bdea8339fdb27325d891a81ee7e05117ec8;p=collectd.git diff --git a/src/processes.c b/src/processes.c index dcdaaf29..aa47f332 100644 --- a/src/processes.c +++ b/src/processes.c @@ -25,7 +25,7 @@ * * Authors: * Lyonel Vincent - * Florian octo Forster + * Florian octo Forster * Oleg King * Sebastian Harl * Andrés J. Díaz @@ -128,8 +128,12 @@ # include #endif -#ifndef ARG_MAX -# define ARG_MAX 4096 +#ifndef CMDLINE_BUFFER_SIZE +# if defined(ARG_MAX) && (ARG_MAX < 4096) +# define CMDLINE_BUFFER_SIZE ARG_MAX +# else +# define CMDLINE_BUFFER_SIZE 4096 +# endif #endif typedef struct procstat_entry_s @@ -223,7 +227,7 @@ static int pagesize; int getprocs64 (void *procsinfo, int sizproc, void *fdsinfo, int sizfd, pid_t *index, int count); int getthrds64( pid_t, void *, int, tid64_t *, int ); #endif -int getargs (struct procentry64 *processBuffer, int bufferLen, char *argsBuffer, int argsLen); +int getargs (void *processBuffer, int bufferLen, char *argsBuffer, int argsLen); #endif /* HAVE_PROCINFO_H */ /* put name of process from config to list_head_g tree @@ -1230,10 +1234,8 @@ static int ps_read_process(int pid, procstat_t *ps, char *state) { char filename[64]; char f_psinfo[64], f_usage[64]; - int i; char *buffer; - pstatus_t *myStatus; psinfo_t *myInfo; prusage_t *myUsage; @@ -1688,7 +1690,7 @@ static int ps_read (void) DIR *proc; int pid; - char cmdline[ARG_MAX]; + char cmdline[CMDLINE_BUFFER_SIZE]; int status; procstat_t ps; @@ -1826,7 +1828,7 @@ static int ps_read (void) * filter out threads (duplicate PID entries). */ if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid)) { - char cmdline[ARG_MAX] = ""; + char cmdline[CMDLINE_BUFFER_SIZE] = ""; _Bool have_cmdline = 0; proc_ptr = &(procs[i]); @@ -2080,7 +2082,7 @@ static int ps_read (void) procstat_t *ps_ptr; char state; - char cmdline[ARG_MAX]; + char cmdline[PRARGSZ]; ps_list_reset ();