Quantcast
Channel: Getting the full path of a running PID with C/C++ without using the system function (Linux) - Stack Overflow
Browsing index pages (3 articles)

Getting the full path of a running PID with C/C++ without using the system...

So I want to be able to get the full path of a running process (which I have the process ID for) without using any commands on the command line. Anyone has any ideas on how to do this?I do have the...

View Article


Answer by nneonneo for Getting the full path of a running PID with C/C++...

Use readlink("/proc/<pid>/exe", buf, bufsize) to get the path to <pid>'s executable. This works on Linux, provided procfs is available (it usually is).Example usage:int...

View Article


Answer by Koshinae for Getting the full path of a running PID with C/C++...

man 3 realpathThis expands all symlink and directory relative token. Sadly, it is GNU specific, I use it with -std=gnu99, like printf("%s\n", realpath("/proc/self/exe", NULL)).

View Article
Browsing index pages (3 articles)


Latest Images