1

I am using OSXFuse and get the processID of the application that wants to read a file in the FUSE Filesystem on Mac. Using the OSXFuse [GMUserFileSystem currentContext], we fetch the process ID and now I would like to get the application name from this process ID. Most of the time, Finder is the calling process and its running under current logged in User privileges. I am trying to pass the process ID to runningApplicationWithProcessIdentifier: to fetch the process details including its name. However runningApplicationWithProcessIdentifier: returns nil. I have ensured the process ID is valid and also under user privileges. What might be wrong?

I am aware there are other ways like using some raw C based api's for fetching the process name, but I would like to fetch it using runningApplicationWithProcessIdentifier: as it can give more useful information

Anish
  • 390
  • 5
  • 16
  • I have exact the same behavior. NSRunningApplication *appFromPid = [NSRunningApplication runningApplicationWithProcessIdentifier:pid]; NSString *bundleId = appFromPid.bundleIdentifier; I believe not every app has bundle id. – DoN1cK Jun 22 '17 at 15:55
  • "I am aware there are other ways like using some raw C based api's for fetching the process name" Can you give me clue? Which Api i can use? – DoN1cK Jun 22 '17 at 16:00
  • Here is the C style code to fetch the process path `GetProcessPathForID(int processID){ pid_t pid; int result; char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; pid = (pid_t)processID; result = proc_pidpath (pid, pathbuf, sizeof(pathbuf)); NSString *processPath = @""; if ( result > 0 ) { processPath = [NSString stringWithCString:pathbuf encoding:NSASCIIStringEncoding]; } return processPath.UTF8String; }` – Anish Jun 23 '17 at 03:27
  • Thanks! I need this because system archiver have bundle id com.apple.finder the same as finder. I uses bundle id for filtering app access – DoN1cK Jun 27 '17 at 07:09

0 Answers0