Skip to content

Conversation

miguelangel-dev
Copy link
Member

@miguelangel-dev miguelangel-dev commented Feb 6, 2020

Description

I have found, some commands are not working properly because it can not find system binaries. It is because some executors have not set up the environment.

How has it been developed?

  • InteractiveTaskExecutor
  • LogTaskExecutor

Both are using posix_spawn C-function call, and the last argument is the environment.

public func posix_spawn(_: UnsafeMutablePointer<pid_t>!, 
                        _: UnsafePointer<Int8>!, 
                        _: UnsafePointer<posix_spawn_file_actions_t?>!, 
                        _: UnsafePointer<posix_spawnattr_t?>!, 
                        _ __argv: UnsafePointer<UnsafeMutablePointer<Int8>?>!, 
                        _ __envp: UnsafePointer<UnsafeMutablePointer<Int8>?>!) -> Int32

so we need to set up this envp: UnsafePointer<UnsafeMutablePointer<Int8>?>! equivalent to [*CChar] (~[String]). If we go to documentation we could read:

       envp is an
       array of strings, conventionally of the form key=value, which are
       passed as environment to the new program.  The envp arrays
       must each include a null pointer at the end of the array.

To get the inheritance environment from the user shell, we can use a top-level function in Foundation - Process. If we use this process and ask for the environment we could inject it to the low-level C-function (after some low-level transformations), that's the idea! ^^

@truizlop truizlop merged commit f8920ed into master Feb 6, 2020
@miguelangel-dev miguelangel-dev deleted the environment branch February 12, 2020 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants