Access argv source pointer from Haskell

Is it possible to access the original argv pointer from Haskell main ?

My use case is that I want to remove command line options after starting the application so that they cannot be read via ps . There are several ways to do this, but all require manipulating the original argv .

I can do this if I write a C wrapper and call hs_init from there (after that using argv ala here ), but it's Better to do it from Haskell.

Thanks!

PS - this question is different from duplicate , because the duplicate uses prctl , which, as far as I can tell, allows you to change the name of the process. In addition, the duplicate is looking to "install" argv[0] , while I'm trying to get a mutable link to the original argv , used to invoke a program.

+5
source share
1 answer

I would look at the System.Posix.Env.ByteString (link) module from the unix package.

It contains functions for changing the environment, and although it provides only getArgs , it's easy to add the setArgs function.

0
source

Source: https://habr.com/ru/post/1210278/


All Articles