Skip to content

Commit

Permalink
live: Allow --list-event without argument
Browse files Browse the repository at this point in the history
The option itself doesn't take an argument.  But current option parsing
logic didn't allow live (or default) command running without an argument
(for target executable).  This is good for normal cases but --list-event
can run without argument and it'll just try to print kernel events if it
is root.  See #923.

Signed-off-by: Namhyung Kim <[email protected]>
  • Loading branch information
namhyung committed Dec 18, 2023
1 parent 8f947dc commit 594ee00
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmds/live.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ int command_live(int argc, char *argv[], struct uftrace_opts *opts)
if (geteuid() == 0)
list_kernel_events();

if (fork() == 0) {
if (opts->exename && fork() == 0) {
setup_child_environ(opts);
setenv("UFTRACE_LIST_EVENT", "1", 1);

Expand Down
2 changes: 1 addition & 1 deletion uftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ int main(int argc, char *argv[])
if (opts.opt_file)
parse_opt_file(&argc, &argv, opts.opt_file, &opts);

if (opts.exename == NULL) {
if (opts.exename == NULL && !opts.list_event) {
switch (opts.mode) {
case UFTRACE_MODE_RECORD:
case UFTRACE_MODE_LIVE:
Expand Down

0 comments on commit 594ee00

Please sign in to comment.