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

GHC ghc-devs at haskell.org
Sun May 25 22:51:38 UTC 2014


#9143: feature request: way to set actual program argv
----------------------------------------------+----------------------------
       Reporter:  joeyhess                    |             Owner:
           Type:  feature request             |  simonmar
       Priority:  normal                      |            Status:  new
      Component:  Runtime System              |         Milestone:
       Keywords:                              |           Version:  7.8.2
   Architecture:  Unknown/Multiple            |  Operating System:  Linux
     Difficulty:  Moderate (less than a day)  |   Type of failure:
     Blocked By:                              |  None/Unknown
Related Tickets:                              |         Test Case:
                                              |          Blocking:
----------------------------------------------+----------------------------
 It's not currently possible to write a program with ghc that changes its
 argv, so as to change what the program name/parameters appear to be in ps.

 An example of a program that does this is sshd, which arranges for the
 process name to say which user it's serving. For example, "sshd: joey
 [priv]"

 I'd like to be able to write such programs using haskell too. Also, I have
 a haskell program that, due to the way it is executed, has a really
 horrible display in ps:

 /usr/local/propellor/docker/android-git-annex-
 builder.orca.kitenet.net.propellor.shim/lib64/ld-linux-x86-64.so.2
 --library-path /usr/local/propellor/docker/android-git-annex-
 builder.orca.kitenet.net.propellor.shim/lib/x86_64-linux-
 gnu:/usr/local/propellor/docker/android-git-annex-
 builder.orca.kitenet.net.propellor.shim/usr/lib/x86_64-linux-
 gnu:/usr/local/propellor/docker/android-git-annex-
 builder.orca.kitenet.net.propellor.shim/lib64:/usr/local/propellor/docker
 /android-git-annex-
 builder.orca.kitenet.net.propellor.shim/etc/ld.so.conf.d:/usr/local/propellor/docker
 /android-git-annex-builder.orca.kitenet.net.propellor.shim/usr/lib/x86_64
 -linux-gnu/audit:/usr/local/propellor/docker/android-git-annex-
 builder.orca.kitenet.net.propellor.shim/usr/lib/x86_64-linux-gnu/gconv
 /usr/local/propellor/propellor

 That's enough motivation for me to dig into this. :)

 In rts/RtsMain.c, progargv is set to point to argv. However, it's static,
 so this cannot be (ab)used from the FFI to change argv.

 So, a minimal change would be to make progargv not be static, and perhaps
 give it a more formal name or minimal FFI binding. A GHC-specific library
 could then use this to modify argv.

 The haskell interface I'm considering would be:

 displayArgv :: [String] -> IO ()

 It would need to truncate strings to fit within the available argv space.

 (This would not affect the argv used by System.Environment, which is a
 copy of argv.)

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


More information about the ghc-tickets mailing list