Add PID helper

This commit is contained in:
Pragyansh Chaturvedi
2025-09-19 22:58:16 +05:30
parent 95727e3374
commit b0f18229d9
3 changed files with 24 additions and 2 deletions

View File

@ -1,5 +1,5 @@
from pythonbpf import bpf, map, section, bpfglobal, compile
from pythonbpf.helpers import ktime, deref
from pythonbpf.helpers import ktime, pid
from pythonbpf.maps import HashMap
from ctypes import c_void_p, c_int64, c_int32, c_uint64
@ -9,7 +9,8 @@ from ctypes import c_void_p, c_int64, c_int32, c_uint64
@section("tracepoint/syscalls/sys_enter_clone")
def hello(ctx: c_void_p) -> c_int32:
ts = ktime()
print(f"clone called at {ts}")
process_id = pid()
print(f"clone called at {ts} by pid {process_id}")
return c_int32(0)