Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

record: suggestion for fallback with named pipe creation #1805

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cmds/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,12 @@ int do_main_loop(int ready, struct uftrace_opts *opts, int pid)

xasprintf(&channel, "%s/%s", opts->dirname, ".channel");

/* try fallback fifo under tmpfs */
if (access(channel, F_OK) != 0) {
free(channel);
xasprintf(&channel, "/tmp/%s%s", opts->dirname, ".channel");
}

wd.pid = pid;
wd.pipefd = open(channel, O_RDONLY | O_NONBLOCK);

Expand Down Expand Up @@ -2269,8 +2275,13 @@ int command_record(int argc, char *argv[], struct uftrace_opts *opts)
return -1;

xasprintf(&channel, "%s/%s", opts->dirname, ".channel");
if (mkfifo(channel, 0600) < 0)
pr_err("cannot create a communication channel");
if (mkfifo(channel, 0600) < 0) {
free(channel);
/* try fallback fifo under tmpfs */
xasprintf(&channel, "/tmp/%s%s", opts->dirname, ".channel");
if (mkfifo(channel, 0600) < 0)
pr_err("cannot create a communication channel");
}
}

fflush(stdout);
Expand Down
6 changes: 6 additions & 0 deletions libmcount/mcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,12 @@ static __used void mcount_startup(void)
char *channel = NULL;

xasprintf(&channel, "%s/%s", dirname, ".channel");
/* try fallback fifo under tmpfs */
if (access(channel, F_OK) != 0) {
free(channel);
xasprintf(&channel, "/tmp/%s%s", dirname, ".channel");
}

pfd = open(channel, O_WRONLY);
free(channel);
}
Expand Down
1 change: 1 addition & 0 deletions libtraceevent/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ libtraceevent.a
*.so
.*.cmd
.*.d
.*.d.*