killsnoop(8)

πŸ“¦ version 1.0.1~20200130+git49b8cdf, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ killsnoop(8) ✨

okay bestie, welcome to killsnoop from the System Manager's Manual β€” she traces kill() syscalls and gives you the process AND signal deets, using Linux ftrace. it's giving detective energy fr fr πŸ”πŸ’…


🌸 SYNOPSIS 🌸

killsnoop [-hst] [-d secs] [-p pid] [-n name]

πŸ’– DESCRIPTION πŸ’–

so basically, this traces kill() syscalls. it shows you which process killed which pid, and it hands you the returncode too β€” that's 0 for success, -1 for error. slay.

this implementation was built to work on older kernel versions and without kernel debuginfo. the way it does it: dynamic tracing of the return value of kill(), then associating that with the previous kill() syscall return. ngl, this approach is kernel version specific and may not work on your version 😭. it's a workaround, and a proof of concept for ftrace, until more kernel tracing functionality is available. periodt.

since this uses ftrace, only the root user can use this tool. no root, no vibes. πŸ’€

πŸŽ€ REQUIREMENTS πŸŽ€

  • FTRACE and KPROBE CONFIG
  • the kernel tracepoints syscalls:sys_enter_kill and syscalls:sys_exit_kill (you may already have these on recent kernels, lucky you ✨)
  • and awk

πŸ’… OPTIONS πŸ’…

  • -d secs β€” set how long you wanna trace, in seconds. trace output gets buffered and printed at the end. this also reduces overheads by buffering in-kernel instead of printing events as they occur. iconic efficiency behavior.

the ftrace buffer has a fixed size per-CPU (see /sys/kernel/debug/tracing/buffer_size_kb). if you think events are missing, try increasing that size. don't let the buffer ghost you πŸ‘»

  • -h β€” print the usage message. that's it, that's the whole job 🫢
  • -n name β€” only show processes matching this process name. partial strings and regular expressions are allowed. this one is post-filtered using awk.
  • -p PID β€” only trace this process ID. this is filtered in-kernel (fancy!).
  • -s β€” use human readable signal names instead of signal numbers. because SIGKILL just hits different than 9 πŸ’…
  • -t β€” include timestamps, in seconds. ⏰

🌈 EXAMPLES 🌈

trace all kill() syscalls with details:

# killsnoop

trace kill() syscalls with readable signal names, and times:

# killsnoop -st

track kill() syscalls for processes named "httpd":

# killsnoop -n httpd

πŸ¦‹ FIELDS πŸ¦‹

  • TIMEs β€” time of open() completion, in units of seconds.
  • COMM β€” process name (if known) of the process that issued the signal.
  • PID β€” process ID that issued the signal.
  • TPID β€” target PID for the signal.
  • SIGNAL β€” signal number sent to the target process, or name if -s is used.
  • RETURN β€” return status: 0 for success, -1 for failure.

πŸ”₯ OVERHEAD πŸ”₯

this reads kill() syscalls as they occur. for high rates of kills (> 500/s), the overhead may begin to be measurable β€” however, the rate is unlikely to get this high. and if it is: you should investigate why πŸ‘€. test yourself. you can also use the -d mode to buffer output, reducing overheads.


⭐ SOURCE ⭐

this is from the perf-tools collection.

https://github.com/brendangregg/perf-tools

also look under the examples directory for a text file containing example usage, output, and commentary for this tool. iykyk πŸŽ€


πŸ’œ OS πŸ’œ

Linux 🐧


πŸ‘‘ STABILITY πŸ‘‘

Unstable - in development. (she's growing, okay?! main character development arc ✨)


🌸 AUTHOR 🌸

Martin Probst


🫢 SEE ALSO 🫢

tpoint(8), execsnoop(8), opensnoop(8)


okay that's the whole page bestie, no cap πŸ’– this one's from USER COMMANDS, dated 2014-09-15, and it's the killsnoop(8) era β€” go forth and trace those signals, you absolute icon πŸ¦‹βœ¨