summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 01f4a6e)
raw | patch | inline | side by side (parent: 01f4a6e)
author | Florian Forster <octo@collectd.org> | |
Mon, 8 Sep 2014 15:07:39 +0000 (17:07 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 8 Sep 2014 15:07:39 +0000 (17:07 +0200) |
ARG_MAX is quite big on many systems, for example >100 kByte on
GNU/Linux. This is a problem for systems with tight memory constraints,
for example embedded devices.
This patch uses at most 4 kByte for this, which out to be enough for the
vast majority of users. Users with specific requirements can compile
with "CMDLINE_BUFFER_SIZE=${LOTS}" in their CPPFLAGS to override this
default.
Fixes: #652
GNU/Linux. This is a problem for systems with tight memory constraints,
for example embedded devices.
This patch uses at most 4 kByte for this, which out to be enough for the
vast majority of users. Users with specific requirements can compile
with "CMDLINE_BUFFER_SIZE=${LOTS}" in their CPPFLAGS to override this
default.
Fixes: #652
src/processes.c | patch | blob | history |
diff --git a/src/processes.c b/src/processes.c
index 5601d290eec7e8f5c3ec79e726156889bf63b00b..aa47f3328f86355ba020ab2730ce237503f9aa4e 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
# include <kstat.h>
#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
DIR *proc;
int pid;
- char cmdline[ARG_MAX];
+ char cmdline[CMDLINE_BUFFER_SIZE];
int status;
procstat_t ps;
* 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]);