killsnoop(8)

πŸ“¦ version 0.36.1, in centos-stream 10, centos-stream 9, fedora 43, fedora 44

πŸŽ€ NAME πŸŽ€

Okay bestie, meet killsnoop(8) from the System Manager's Manual πŸ’…. It traces signals sent with the kill() syscall, and it runs on Linux using eBPF/bcc ✨.

πŸ¦‹ SYNOPSIS πŸ¦‹

killsnoop [-h] [-x] [-p PID] [-T PID] [-s SIGNAL]

πŸ’– DESCRIPTION πŸ’–

So killsnoop watches the kill() syscall and shows you every signal that gets sent that way πŸ‘€. This is lowkey perfect when an app is failing and you have no clue what's sending it signals 😭.

It works by tracing the kernel sys_kill() function with dynamic tracing. Because of that, it'll need updating whenever that function changes πŸ› οΈ.

It uses a Linux 4.4 feature, bpf_perf_event_output(). If your kernel is older than 4.4, check out the version under tools/old, which uses an older mechanism 🌸.

Also, since this runs on BPF, only the root user can use this tool πŸ”₯. No cap.

🌈 REQUIREMENTS 🌈

You need CONFIG_BPF and bcc ✨.

✨ OPTIONS ✨

  • -h β€” Shows the usage message πŸ’œ.
  • -x β€” Only shows kill() syscalls that failed πŸ’€.
  • -p PID β€” Only traces this process ID, the one sending the signal. It gets filtered in-kernel 🧚.
  • -T PID β€” Only traces this target process ID, the one receiving the signal. It also gets filtered in-kernel 🎯.
  • -s SIGNAL β€” Only traces this signal. It gets filtered in-kernel too πŸ“.

🫢 EXAMPLES 🫢

Trace all kill() syscalls:

# killsnoop

Trace only the kill() syscalls that failed:

# killsnoop -x

Trace PID 181 only:

# killsnoop -p 181

Trace target PID 189 only:

# killsnoop -T 189

Trace signal 9 only:

# killsnoop -s 9

🧚 FIELDS 🧚

  • TIME β€” When the kill call happened ⏰.
  • PID β€” The source process ID πŸͺͺ.
  • COMM β€” The source process name πŸ“›.
  • SIG β€” The signal number. Check out signal(7) for the details πŸ“–.
  • TPID β€” The target process ID 🎯.
  • RES β€” The result. 0 means success. A negative value (the error code) means it failed πŸ’”.

⏳ OVERHEAD ⏳

This traces the kernel kill function and prints output for every event. The rate is usually expected to be low (< 100/s), so the overhead should be negligible 🌷. But if your app is calling kill() at a super high rate for some reason, test and understand the overhead before you use it 😬.

🌐 SOURCE 🌐

This comes from bcc πŸ’œ. Source: https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool πŸ“š.

πŸ’» OS πŸ’»

Linux 🐧.

πŸ§ͺ STABILITY πŸ§ͺ

Unstable, still in development 🚧.

πŸ‘‘ AUTHOR πŸ‘‘

Brendan Gregg, the legend himself πŸ™Œ.

πŸ”— SEE ALSO πŸ”—

opensnoop(8), funccount(8) 🫢.


Okay that's the tea, bestie πŸ’…πŸŽ€. This page is from the USER COMMANDS section and was last updated on 2015-08-20 🌸. Stay iconic and keep tracing those signals πŸ¦‹βœ¨.

πŸ“¦ where this page comes from