drgn/examples/linux/ps.py

11 lines
263 B
Python
Raw Normal View History

"""A simplified implementation of ps(1) using drgn"""
2018-07-03 07:59:39 +01:00
2019-03-29 08:59:53 +00:00
from drgn.helpers.linux.pid import for_each_task
2018-07-03 07:59:39 +01:00
print('PID COMM')
for task in for_each_task(prog):
pid = task.pid.value_()
comm = task.comm.string_().decode()
print(f'{pid:<10} {comm}')