In macOS X , I am monitoring all process launch event. When process launches I am getting PID from kernel. And using that PID I am retrieving full process Path in user mode.
I am using proc_pidpath() for process lauch event only. If I try to get process path of already running process it works .
#define MAX_PROCESS_PATH_LEN 1024
int iReturn;
char ProcessPath[MAX_PROCESS_PATH_LEN];
iReturn = proc_pidpath(processID , processPath , sizeof(ProcessPath));
if(0 == iReturn)
{
// proc_pidpath failed
}
else
{
NSLog(@"My Process Path = %s" , ProcessPath);
}
Input Task : launch Chess.app from /Application/Chess.app
Actual Output : My Process Path = /sbin/launchd
Expected output is /Application/Chess.app or /Applications/Chess.app/Contents/MacOS/Chess.
Can anyone please help me how to get process path when process is fork but may be not initialised ?