macOS `ps` gives bundle identifier instead of path for some XPC services












0















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?










share|improve this question





























    0















    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?










    share|improve this question



























      0












      0








      0








      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?










      share|improve this question
















      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?







      macos xpc launch-services






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 20:47







      Jerry Krinock

















      asked Nov 14 '18 at 20:06









      Jerry KrinockJerry Krinock

      1,6171620




      1,6171620
























          1 Answer
          1






          active

          oldest

          votes


















          1














          A program can a) rewrite the memory pointed to by argv and the strings it points to, and/or b) call setprogname().



          I seem to recall that setprogname() does not affect the output of ps, but rewriting argv does. I could have that backwards, though. I know that Wine does both and affects the command that ps sees.






          share|improve this answer
























          • Wow, that is wild, Ken. My helper app certainly does not touch argv nor call setprogname(). However, this is interesting, because certainly such manipulations are somehow within the powers of Apple's launchd.

            – Jerry Krinock
            Nov 15 '18 at 1:07











          • Launchd might do it. So might XPC in the launched service, somehow.

            – Ken Thomases
            Nov 15 '18 at 4:13











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307987%2fmacos-ps-gives-bundle-identifier-instead-of-path-for-some-xpc-services%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          A program can a) rewrite the memory pointed to by argv and the strings it points to, and/or b) call setprogname().



          I seem to recall that setprogname() does not affect the output of ps, but rewriting argv does. I could have that backwards, though. I know that Wine does both and affects the command that ps sees.






          share|improve this answer
























          • Wow, that is wild, Ken. My helper app certainly does not touch argv nor call setprogname(). However, this is interesting, because certainly such manipulations are somehow within the powers of Apple's launchd.

            – Jerry Krinock
            Nov 15 '18 at 1:07











          • Launchd might do it. So might XPC in the launched service, somehow.

            – Ken Thomases
            Nov 15 '18 at 4:13
















          1














          A program can a) rewrite the memory pointed to by argv and the strings it points to, and/or b) call setprogname().



          I seem to recall that setprogname() does not affect the output of ps, but rewriting argv does. I could have that backwards, though. I know that Wine does both and affects the command that ps sees.






          share|improve this answer
























          • Wow, that is wild, Ken. My helper app certainly does not touch argv nor call setprogname(). However, this is interesting, because certainly such manipulations are somehow within the powers of Apple's launchd.

            – Jerry Krinock
            Nov 15 '18 at 1:07











          • Launchd might do it. So might XPC in the launched service, somehow.

            – Ken Thomases
            Nov 15 '18 at 4:13














          1












          1








          1







          A program can a) rewrite the memory pointed to by argv and the strings it points to, and/or b) call setprogname().



          I seem to recall that setprogname() does not affect the output of ps, but rewriting argv does. I could have that backwards, though. I know that Wine does both and affects the command that ps sees.






          share|improve this answer













          A program can a) rewrite the memory pointed to by argv and the strings it points to, and/or b) call setprogname().



          I seem to recall that setprogname() does not affect the output of ps, but rewriting argv does. I could have that backwards, though. I know that Wine does both and affects the command that ps sees.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 0:10









          Ken ThomasesKen Thomases

          70.3k670107




          70.3k670107













          • Wow, that is wild, Ken. My helper app certainly does not touch argv nor call setprogname(). However, this is interesting, because certainly such manipulations are somehow within the powers of Apple's launchd.

            – Jerry Krinock
            Nov 15 '18 at 1:07











          • Launchd might do it. So might XPC in the launched service, somehow.

            – Ken Thomases
            Nov 15 '18 at 4:13



















          • Wow, that is wild, Ken. My helper app certainly does not touch argv nor call setprogname(). However, this is interesting, because certainly such manipulations are somehow within the powers of Apple's launchd.

            – Jerry Krinock
            Nov 15 '18 at 1:07











          • Launchd might do it. So might XPC in the launched service, somehow.

            – Ken Thomases
            Nov 15 '18 at 4:13

















          Wow, that is wild, Ken. My helper app certainly does not touch argv nor call setprogname(). However, this is interesting, because certainly such manipulations are somehow within the powers of Apple's launchd.

          – Jerry Krinock
          Nov 15 '18 at 1:07





          Wow, that is wild, Ken. My helper app certainly does not touch argv nor call setprogname(). However, this is interesting, because certainly such manipulations are somehow within the powers of Apple's launchd.

          – Jerry Krinock
          Nov 15 '18 at 1:07













          Launchd might do it. So might XPC in the launched service, somehow.

          – Ken Thomases
          Nov 15 '18 at 4:13





          Launchd might do it. So might XPC in the launched service, somehow.

          – Ken Thomases
          Nov 15 '18 at 4:13




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307987%2fmacos-ps-gives-bundle-identifier-instead-of-path-for-some-xpc-services%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine