In C program in linux, we can use getpid()
and getppid()
system call to get the pid and ppid of a process,
Similarly is there any system call to get name of a process/current process?
In C program in linux, we can use getpid()
and getppid()
system call to get the pid and ppid of a process,
Similarly is there any system call to get name of a process/current process?
You can have a look at the /proc/$pid/cmdline
file (open it like a normal file and read the zero-byte-delimited command line from it).
That's the way the Unix tool ps
does it on Linux.
More solutions can be found here: How to get current process name in linux?
I implemented the solution using the program_invocation_name
variable.