feature request: way to set actual program argv
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.)