Skip to content

Commit

Permalink
execsnoop: don't print newlines in argv
Browse files Browse the repository at this point in the history
by escaping newlines. Fixes iovisor#1037

* Before:
```
$ sudo /usr/share/bcc/tools/execsnoop
PCOMM            PID    PPID   RET ARGS
awk              9910   7831     0 /usr/bin/awk
BEGIN { print "hi" }
```

* With this patch:
```
$ sudo /usr/share/bcc/tools/execsnoop
PCOMM            PID    PPID   RET ARGS
awk              10033  7831     0 /usr/bin/awk \nBEGIN { print "hi" }
```
  • Loading branch information
javierhonduco committed May 21, 2018
1 parent 2867473 commit 5340c21
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/execsnoop.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@ def print_event(cpu, data, size):
print("%-8.3f" % (time.time() - start_ts), end="")
ppid = get_ppid(event.pid)
ppid = b"%d" % ppid if ppid > 0 else b"?"
argv_text = b' '.join(argv[event.pid]).replace(b'\n', b'\\n')
printb(b"%-16s %-6d %-6s %3d %s" % (event.comm, event.pid,
ppid, event.retval, b' '.join(argv[event.pid])))
ppid, event.retval, argv_text))
try:
del(argv[event.pid])
except Exception:
Expand Down

0 comments on commit 5340c21

Please sign in to comment.