My macOS app can launch a faceless helper application which is shipped in its Contents/Library/LoginItems using Apple's Service Management Framework, as described in Apple documentation. Funny thing is, when I request the unix ps program to give me the command/paths, for this helper process, it gives the bundle identifier instead. Example:
jk$ ps -x -o command
...
com.mycompany.MyAgent
...
It gives me the same answer with or without the -c option on ps.
Because my app comes in several flavors and versions which each contain different helpers, and because users may have multiple installations, and because of the sometimes strange behavior of Launch Services, for self-testing and diagnostic purposes, I would like to get the path to the running helper's package or executable.
Why does ps give the bundle identifier instead? How can I get the path?
A program can a) rewrite the memory pointed to by
argvand the strings it points to, and/or b) callsetprogname().I seem to recall that
setprogname()does not affect the output ofps, but rewritingargvdoes. I could have that backwards, though. I know that Wine does both and affects the command thatpssees.