Search code examples
kernelminix

How to get the process name from server layer using PID


I would like to be able to use the name of the process in servers/sched/schedule.c however schedproc structure doesn't contain the name variable. I thought about using endpoint_lookup() function to get the pointer to the proc structure but since it is defined in kernel/proc.c I wasn't sure if I could call it within schedule.c (from user space).


Solution

  • In user space, you could use /proc/<pid>/cmdline to get the process's name, like

    $cat /proc/$$/cmdline 
    

    bash