+/*
+ * get_cmdline_by_pid
+ *
+ * Get command line from /proc for a
+ * specific pid. Allocate cmdline so the
+ * user must free() that pointer.
+ *
+ * On success, return 1
+ * On error (not found), return 0
+ */
+static int get_cmdline_by_pid(pid_t pid, char **cmdline)
+{
+ int ret;
+ FILE *fp;
+ char path[24]; /* Can't go bigger than /proc/65535/cmdline */
+
+ snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
+ fp = fopen(path, "r");
+ if (fp == NULL) {
+ goto not_running;
+ }
+
+ /* Caller must free() *cmdline */
+ *cmdline = malloc(PATH_MAX);
+ ret = fread(*cmdline, 1, PATH_MAX, fp);
+ fclose(fp);
+
+ return 1;
+
+not_running:
+ return 0;
+}
+
+/*
+ * validate_options
+ *
+ * Make sure that all options passed to the command line
+ * are compatible with each others.
+ *
+ * On error, return -1
+ * On success, return 0
+ */
+static int validate_options(void)
+{
+ if ((opt_session_uuid == NULL) &&
+ (opt_create_trace || opt_start_trace || opt_list_traces)) {
+ ERR("You need to specify a session UUID.\nPlease use --session UUID to do so.");
+ goto error;
+ }
+
+ return 0;
+
+error:
+ return -1;
+}
+