Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,248
    • Issues 4,248
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 391
    • Merge Requests 391
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9143

Closed
Open
Opened May 25, 2014 by joeyhess@trac-joeyhess

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.)

Edited Mar 10, 2019 by Ben Gamari
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9143