[GHC] #9143: feature request: way to set actual program argv

GHC ghc-devs at haskell.org
Sun Nov 16 20:07:52 UTC 2014


#9143: feature request: way to set actual program argv
-------------------------------------+-------------------------------------
              Reporter:  joeyhess    |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.8.2
             Component:  Runtime     |         Keywords:
  System                             |     Architecture:  Unknown/Multiple
            Resolution:              |       Difficulty:  Moderate (less
      Operating System:  Linux       |  than a day)
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
Changes (by thomie):

 * owner:  simonmar =>
 * status:  closed => new
 * resolution:  wontfix =>


Comment:

 Or maybe that stackoverflow answer is not out of date, but it's just only
 one half of the story? I added this comment: "This seems to only change
 the name in the output of 'ps -A', 'ps -a' 'ps -d', 'ps -e' and maybe
 others, whereas 'ps a', 'ps -ef', 'ps f' and probably others still show
 the original command line arguments."

 Changing argv[0] would then be the other half of the story, like you
 suggested in the description. This C example shows "othername" when using
 'ps -ef', but not when doing 'ps -e'. In `top` you can toggle between the
 two by hitting the `c` key.
 {{{
 #include <unistd.h>
 #include <string.h>

 int main(int argc, char** argv) {
    strcpy(argv[0],"othername");
    sleep(1000);
    return 0;
 }
 }}}

 So doing both would be needed: change `argv` and call `prctl`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9143#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list