hie-bios
Safe HaskellSafe-Inferred
LanguageHaskell2010

HIE.Bios.Process

Synopsis

Documentation

data CreateProcess #

Constructors

CreateProcess 

Fields

  • cmdspec :: CmdSpec

    Executable & arguments, or shell command. If cwd is Nothing, relative paths are resolved with respect to the current working directory. If cwd is provided, it is implementation-dependent whether relative paths are resolved with respect to cwd or the current working directory, so absolute paths should be used to ensure portability.

  • cwd :: Maybe FilePath

    Optional path to the working directory for the new process

  • env :: Maybe [(String, String)]

    Optional environment (otherwise inherit from the current process)

  • std_in :: StdStream

    How to determine stdin

  • std_out :: StdStream

    How to determine stdout

  • std_err :: StdStream

    How to determine stderr

  • close_fds :: Bool

    Close all file descriptors except stdin, stdout and stderr in the new process (on Windows, only works if std_in, std_out, and std_err are all Inherit). This implementation will call close on every fd from 3 to the maximum of open files, which can be slow for high maximum of open files. XXX verify what happens with fds in nodejs child processes

  • create_group :: Bool

    Create a new process group. On JavaScript this also creates a new session.

  • delegate_ctlc :: Bool

    Delegate control-C handling. Use this for interactive console processes to let them handle control-C themselves (see below for details).

    Since: process-1.2.0.0

  • detach_console :: Bool

    Use the windows DETACHED_PROCESS flag when creating the process; does nothing on other platforms.

    Since: process-1.3.0.0

  • create_new_console :: Bool

    Use the windows CREATE_NEW_CONSOLE flag when creating the process; does nothing on other platforms.

    Default: False

    Since: process-1.3.0.0

  • new_session :: Bool

    Use posix setsid to start the new process in a new session; starts process in a new session on JavaScript; does nothing on other platforms.

    Since: process-1.3.0.0

  • child_group :: Maybe GroupID

    Use posix setgid to set child process's group id; works for JavaScript when system running nodejs is posix. does nothing on other platforms.

    Default: Nothing

    Since: process-1.4.0.0

  • child_user :: Maybe UserID

    Use posix setuid to set child process's user id; works for JavaScript when system running nodejs is posix. does nothing on other platforms.

    Default: Nothing

    Since: process-1.4.0.0

  • use_process_jobs :: Bool

    On Windows systems this flag indicates that we should wait for the entire process tree to finish before unblocking. On POSIX systems this flag is ignored. See $exec-on-windows for details.

    Default: False

    Since: process-1.5.0.0

Instances

Instances details
Show CreateProcess 
Instance details

Defined in System.Process.Common

Eq CreateProcess 
Instance details

Defined in System.Process.Common

Run processes with extra environment variables

readProcessWithCwd :: LogAction IO (WithSeverity Log) -> FilePath -> FilePath -> [String] -> String -> IO (CradleLoadResult String) Source #

Wrapper around readCreateProcess that sets the working directory and clears the environment, suitable for invoking cabal/stack and raw ghc commands.

readProcessWithCwd' :: LogAction IO (WithSeverity Log) -> CreateProcess -> String -> CradleLoadResultT IO String Source #

Wrapper around readCreateProcessWithExitCode, wrapping the result in a CradleLoadResult. Provides better error messages than raw readCreateProcess.

readProcessWithOutputs Source #

Arguments

:: Outputs

Names of the outputs produced by this process

-> LogAction IO (WithSeverity Log)

Output of the process is emitted as logs.

-> FilePath

Working directory. Process is executed in this directory.

-> CreateProcess

Parameters for the process to be executed.

-> IO (ExitCode, [String], [String], [(OutputName, Maybe [String])]) 

Call a given process with temp files for the process to write to. * The process can discover the temp files paths by reading the environment. * The contents of the temp files are returned by this function, if any. * The logging function is called every time the process emits anything to stdout or stderr. it can be used to report progress of the process to a user. * The process is executed in the given directory.

getCleanEnvironment :: IO [(String, String)] Source #

Some environments (e.g. stack exec) include GHC_PACKAGE_PATH. Cabal v2 *will* complain, even though or precisely because it ignores them. Unset them from the environment to sidestep this

File Caching

cacheFile :: FilePath -> String -> (FilePath -> IO ()) -> IO FilePath Source #

Create and cache a file in hie-bios's cache directory.

cacheFile fpName srcHash populate. fpName is the pattern name of the cached file you want to create. srcHash is the hash that is appended to the file pattern and is expected to change whenever you want to invalidate the cache.

If the cached file's srcHash changes, then a new file is created, but the old cached file name will not be deleted.

If the file does not exist yet, populate is invoked with cached file location and it is expected that the caller persists the given filepath in the File System.

Find file utilities

findFileUpwards :: FilePath -> FilePath -> MaybeT IO FilePath Source #

Searches upwards for the first directory containing a file.

findFileUpwardsPredicate :: (FilePath -> Bool) -> FilePath -> MaybeT IO FilePath Source #

Searches upwards for the first directory containing a file to match the predicate.

  • WARNING*, this scans all the files of all the directories upward. If appliable, prefer to use findFileUpwards

findFile :: (FilePath -> Bool) -> FilePath -> IO [FilePath] Source #

Sees if any file in the directory matches the predicate