* Add --socket option if no HOME found (sessiond)
* Use realloc() in ask_sessiond() (liblttngctl)
-* perror() --> PERROR() (everywhere in the code)
* Add a command to "lttng" to consume data when the tracer is in flightrecorder mode
* Fix error handling for UST support when enabling events on all applications.
* Support for UST remaining domains (PID, EXEC_NAME, FOLLOW_CHILDREN).
#include <errno.h>
#include <stdio.h>
#include "fd-limit.h"
+#include <common/error.h>
/* total count of fd. */
static long fd_count;
ret = getrlimit(RLIMIT_NOFILE, &rlim);
if (ret < 0) {
- perror("getrlimit");
+ PERROR("getrlimit");
}
max_nr_fd = rlim.rlim_cur;
}
}
tracing_group_name = strdup(arg);
if (!tracing_group_name) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
tracing_group_name_override = 1;
}
consumerd32_bin = strdup(arg);
if (!consumerd32_bin) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
consumerd32_bin_override = 1;
}
consumerd32_libdir = strdup(arg);
if (!consumerd32_libdir) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
consumerd32_libdir_override = 1;
}
consumerd64_bin = strdup(arg);
if (!consumerd64_bin) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
consumerd64_bin_override = 1;
}
consumerd64_libdir = strdup(arg);
if (!consumerd64_libdir) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
consumerd64_libdir_override = 1;
free(opt_pidfile);
opt_pidfile = strdup(arg);
if (!opt_pidfile) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
break;
free(opt_load_session_path);
opt_load_session_path = strdup(arg);
if (!opt_load_session_path) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
break;
free(kmod_probes_list);
kmod_probes_list = strdup(arg);
if (!kmod_probes_list) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
break;
free(kmod_extra_probes_list);
kmod_extra_probes_list = strdup(arg);
if (!kmod_extra_probes_list) {
- perror("strdup");
+ PERROR("strdup");
ret = -ENOMEM;
}
break;
type = zmalloc(sizeof(struct ctx_type));
if (type == NULL) {
- perror("malloc ctx_type");
+ PERROR("malloc ctx_type");
ret = CMD_FATAL;
goto end;
}
/* Caller must free() *cmdline */
cmdline = zmalloc(PATH_MAX);
if (!cmdline) {
- perror("malloc cmdline");
+ PERROR("malloc cmdline");
goto end;
}
ret = fread(cmdline, 1, PATH_MAX, fp);
if (ret < 0) {
- perror("fread proc list");
+ PERROR("fread proc list");
}
end:
ret = gethostname(hostname, sizeof(hostname));
if (ret < 0) {
- perror("gethostname");
+ PERROR("gethostname");
goto error;
}
ret = asprintf(&path, "net://localhost/host/%s/%s", hostname,
session_name);
if (ret < 0) {
- perror("asprintf live path");
+ PERROR("asprintf live path");
goto error;
}
DBG("Removing %s\n", config_path);
ret = remove(config_path);
if (ret < 0) {
- perror("remove config file");
+ PERROR("remove config file");
}
end:
free(config_path);
sigset_t sigset;
if ((ret = sigemptyset(&sigset)) < 0) {
- perror("sigemptyset");
+ PERROR("sigemptyset");
goto end;
}
sa.sa_mask = sigset;
sa.sa_flags = 0;
if ((ret = sigaction(SIGUSR1, &sa, NULL)) < 0) {
- perror("sigaction");
+ PERROR("sigaction");
goto end;
}
if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
- perror("sigaction");
+ PERROR("sigaction");
goto end;
}
if ((ret = sigaction(SIGCHLD, &sa, NULL)) < 0) {
- perror("sigaction");
+ PERROR("sigaction");
goto end;
}
if (errno == ENOENT) {
ERR("No session daemon found. Use --sessiond-path.");
} else {
- perror("execlp");
+ PERROR("execlp");
}
kill(getppid(), SIGTERM); /* wake parent */
exit(EXIT_FAILURE);
}
goto end;
} else {
- perror("fork");
+ PERROR("fork");
ret = -1;
goto end;
}
if (errno == ENOENT) {
ERR("No relayd found. Use --relayd-path.");
} else {
- perror("execlp");
+ PERROR("execlp");
}
kill(getppid(), SIGTERM); /* wake parent */
exit(EXIT_FAILURE);
} else if (pid > 0) {
goto end;
} else {
- perror("fork");
+ PERROR("fork");
ret = -1;
goto end;
}
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0) {
- perror("socket check relayd");
+ PERROR("socket check relayd");
ret = -1;
goto error_socket;
}
sin.sin_port = htons(DEFAULT_NETWORK_VIEWER_PORT);
ret = inet_pton(sin.sin_family, "127.0.0.1", &sin.sin_addr);
if (ret < 1) {
- perror("inet_pton check relayd");
+ PERROR("inet_pton check relayd");
ret = -1;
goto error;
}
error:
if (close(fd) < 0) {
- perror("close relayd fd");
+ PERROR("close relayd fd");
}
error_socket:
return ret;
/* This *must* be freed by using lttng_poll_free() */
wait->events = zmalloc(size * sizeof(struct pollfd));
if (wait->events == NULL) {
- perror("zmalloc struct pollfd");
+ PERROR("zmalloc struct pollfd");
goto error;
}
current->events = zmalloc(size * sizeof(struct pollfd));
if (current->events == NULL) {
- perror("zmalloc struct current pollfd");
+ PERROR("zmalloc struct current pollfd");
goto error;
}
ret = poll(events->wait.events, events->wait.nb_fd, timeout);
if (ret < 0) {
/* At this point, every error is fatal */
- perror("poll wait");
+ PERROR("poll wait");
goto error;
}
ret = getrlimit(RLIMIT_NOFILE, &lim);
if (ret < 0) {
- perror("getrlimit poll RLIMIT_NOFILE");
+ PERROR("getrlimit poll RLIMIT_NOFILE");
return;
}
if (events->epfd >= 0) {
ret = close(events->epfd);
if (ret) {
- perror("close");
+ PERROR("close");
}
}
ret = lttng_write(fd, (void *) &hdr, sizeof(hdr));
if (ret < sizeof(hdr)) {
/*
- * This error means that the fd's end is closed so ignore the perror
+ * This error means that the fd's end is closed so ignore the PERROR
* not to clubber the error output since this can happen in a normal
* code path.
*/
}
ret = fseek(fp, 0L, SEEK_SET);
if (ret < 0) {
- perror("fseek");
+ PERROR("fseek");
goto error_close;
}
/* We keep the handle open, but can unlink the file on the VFS. */
ret = unlink(tmpname);
if (ret < 0) {
- perror("unlink");
+ PERROR("unlink");
}
return fp;
error_close:
ret = fclose(fp);
if (ret < 0) {
- perror("close");
+ PERROR("close");
}
error_unlink:
ret = unlink(tmpname);
if (ret < 0) {
- perror("unlink");
+ PERROR("unlink");
}
return NULL;
}
*/
ret = unlink(tmpname);
if (ret < 0) {
- perror("unlink");
+ PERROR("unlink");
}
return fp;
error_unlink:
ret = unlink(tmpname);
if (ret < 0) {
- perror("unlink");
+ PERROR("unlink");
}
return NULL;
}
ret = fflush(fp);
if (ret < 0) {
- perror("fflush");
+ PERROR("fflush");
return ret;
}
ret = fseek(fp, 0L, SEEK_END);
if (ret < 0) {
- perror("fseek");
+ PERROR("fseek");
return ret;
}
pos = ftell(fp);
if (ret < 0) {
- perror("ftell");
+ PERROR("ftell");
return ret;
}
*size = pos;
}
ret = fseek(fp, 0L, SEEK_SET);
if (ret < 0) {
- perror("fseek");
+ PERROR("fseek");
goto error_free;
}
/* Copy the entire file into the buffer */
}
ret = fclose(fp);
if (ret < 0) {
- perror("fclose");
+ PERROR("fclose");
return ret;
}
return 0;
error_close:
ret = fclose(fp);
if (ret < 0) {
- perror("fclose");
+ PERROR("fclose");
}
error_free:
free(*buf);
/* Get number of supplementary group IDs */
grp_list_size = getgroups(0, NULL);
if (grp_list_size < 0) {
- perror("getgroups");
+ PERROR("getgroups");
goto end;
}
/* Alloc group list of the right size */
grp_list = zmalloc(grp_list_size * sizeof(gid_t));
if (!grp_list) {
- perror("malloc");
+ PERROR("malloc");
goto end;
}
grp_id = getgroups(grp_list_size, grp_list);
if (grp_id < 0) {
- perror("getgroups");
+ PERROR("getgroups");
goto free_list;
}
ret = lttcomm_close_unix_sock(ret);
if (ret < 0) {
- perror("lttcomm_close_unix_sock");
+ PERROR("lttcomm_close_unix_sock");
}
return 0;
/* No need to keep the memory stream. */
if (fclose(fmem) != 0) {
- perror("fclose");
+ PERROR("fclose");
}
*ctxp = ctx;
filter_parser_ctx_free(ctx);
filter_alloc_error:
if (fclose(fmem) != 0) {
- perror("fclose");
+ PERROR("fclose");
}
error:
return ret;
}
if ((control_sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
- perror("Socket");
+ PERROR("Socket");
ret = -1;
goto end;
}
if (connect(control_sock, (struct sockaddr *) &server_addr,
sizeof(struct sockaddr)) == -1) {
- perror("Connect");
+ PERROR("Connect");
ret = -1;
goto end;
}
data = zmalloc(len);
if (!data) {
- perror("relay data zmalloc");
+ PERROR("relay data zmalloc");
goto error;
}
do {