#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <assert.h>
#include <urcu/list.h>
goto error;
}
if (all) {
- pid_list = zmalloc(sizeof(*_pid_list));
+ pid_list = zmalloc(sizeof(*pid_list));
if (!pid_list) {
ERR("Out of memory");
retval = CMD_ERROR;
} else if (opt_userspace) {
dom.type = LTTNG_DOMAIN_UST;
} else {
- print_missing_domain();
- ret = CMD_ERROR;
- goto end;
+ /* Checked by the caller. */
+ assert(0);
}
ret = parse_pid_string(pid_string, all, &pid_list, &nr_pids);
DBG("%s PID %d", cmd_str, pid_list[i]);
ret = lib_func(handle, pid_list[i]);
if (ret) {
- success = 0;
- retval = CMD_ERROR;
+ switch (-ret) {
+ case LTTNG_ERR_PID_TRACKED:
+ WARN("PID %i already tracked in session %s",
+ pid_list[i], session_name);
+ success = 1;
+ retval = CMD_SUCCESS;
+ break;
+ case LTTNG_ERR_PID_NOT_TRACKED:
+ WARN("PID %i not tracked in session %s",
+ pid_list[i], session_name);
+ success = 1;
+ retval = CMD_SUCCESS;
+ break;
+ default:
+ ERR("%s", lttng_strerror(ret));
+ success = 0;
+ retval = CMD_ERROR;
+ break;
+ }
} else {
+ MSG("PID %i %sed in session %s",
+ pid_list[i], cmd_str, session_name);
success = 1;
}
}
}
- if (!(opt_userspace ^ opt_kernel)) {
- ERR("Exactly one of -u or -k needs to be specified.");
- usage(stderr, cmd_str);
- command_ret = CMD_ERROR;
+ ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace);
+ if (ret) {
+ ret = CMD_ERROR;
goto end;
}