Filter out non-bash COMMs
Prevents the output of non-bash readlines when bash is dynamically
linked. Refs #1851.
diff --git a/tools/bashreadline.py b/tools/bashreadline.py
index 4cc1f96..b7d9827 100755
--- a/tools/bashreadline.py
+++ b/tools/bashreadline.py
@@ -35,6 +35,7 @@
# load BPF program
bpf_text = """
#include <uapi/linux/ptrace.h>
+#include <linux/sched.h>
struct str_t {
u64 pid;
@@ -45,13 +46,19 @@
int printret(struct pt_regs *ctx) {
struct str_t data = {};
+ char comm[TASK_COMM_LEN] = {};
u32 pid;
if (!PT_REGS_RC(ctx))
return 0;
pid = bpf_get_current_pid_tgid();
data.pid = pid;
bpf_probe_read(&data.str, sizeof(data.str), (void *)PT_REGS_RC(ctx));
- events.perf_submit(ctx,&data,sizeof(data));
+
+ bpf_get_current_comm(&comm, sizeof(comm));
+ if (comm[0] == 'b' && comm[1] == 'a' && comm[2] == 's' && comm[3] == 'h' && comm[4] == 0 ) {
+ events.perf_submit(ctx,&data,sizeof(data));
+ }
+
return 0;
};