PROC(5) mentions that "On 64-bit systems, pid_max can be set to any
value up to 2^22 (PID_MAX_LIMIT, approximately 4 million)."
We use 32 bits for simplicity's sake.
Reported-by: Zhenyu Ren <zhenyu.ren@aliyun.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
/*
* Event symbol length. Copied from LTTng kernel ABI.
*/
-#define LTTNG_SYMBOL_NAME_LEN 256
+#define LTTNG_SYMBOL_NAME_LEN 256
+
+/*
+ * PROC(5) mentions that PID_MAX_LIMIT may not exceed 2^22 on 64-bit HW.
+ * We prefer to use 32-bits for simplicity's sake.
+ */
+#define LTTNG_MAX_PID INT32_MAX
+#define LTTNG_MAX_PID_STR "2147483647"
#endif /* LTTNG_CONSTANT_H */
#include <assert.h>
#include <common/mi-lttng.h>
+#include <lttng/constant.h>
#include "../command.h"
int ret;
FILE *fp = NULL;
char *cmdline = NULL;
- char path[20]; /* Can't go bigger than /proc/65535/cmdline */
+ /* Can't go bigger than /proc/LTTNG_MAX_PID/cmdline */
+ char path[sizeof("/proc//cmdline") + sizeof(LTTNG_MAX_PID_STR) - 1];
snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
fp = fopen(path, "r");