{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

This class contains a set of options for launching child processes,
such as where its standard input and output will be directed, the
argument list, the environment, and more.

While the 'GI.Gio.Objects.Subprocess.Subprocess' class has high level functions covering
popular cases, use of this class allows access to more advanced
options.  It can also be used to launch multiple subprocesses with
a similar configuration.
-}

module GI.Gio.Objects.SubprocessLauncher
    ( 

-- * Exported types
    SubprocessLauncher(..)                  ,
    IsSubprocessLauncher                    ,
    toSubprocessLauncher                    ,
    noSubprocessLauncher                    ,


 -- * Methods
-- ** getenv #method:getenv#
    SubprocessLauncherGetenvMethodInfo      ,
    subprocessLauncherGetenv                ,


-- ** new #method:new#
    subprocessLauncherNew                   ,


-- ** setChildSetup #method:setChildSetup#
    SubprocessLauncherSetChildSetupMethodInfo,
    subprocessLauncherSetChildSetup         ,


-- ** setCwd #method:setCwd#
    SubprocessLauncherSetCwdMethodInfo      ,
    subprocessLauncherSetCwd                ,


-- ** setEnviron #method:setEnviron#
    SubprocessLauncherSetEnvironMethodInfo  ,
    subprocessLauncherSetEnviron            ,


-- ** setFlags #method:setFlags#
    SubprocessLauncherSetFlagsMethodInfo    ,
    subprocessLauncherSetFlags              ,


-- ** setStderrFilePath #method:setStderrFilePath#
    SubprocessLauncherSetStderrFilePathMethodInfo,
    subprocessLauncherSetStderrFilePath     ,


-- ** setStdinFilePath #method:setStdinFilePath#
    SubprocessLauncherSetStdinFilePathMethodInfo,
    subprocessLauncherSetStdinFilePath      ,


-- ** setStdoutFilePath #method:setStdoutFilePath#
    SubprocessLauncherSetStdoutFilePathMethodInfo,
    subprocessLauncherSetStdoutFilePath     ,


-- ** setenv #method:setenv#
    SubprocessLauncherSetenvMethodInfo      ,
    subprocessLauncherSetenv                ,


-- ** spawnv #method:spawnv#
    SubprocessLauncherSpawnvMethodInfo      ,
    subprocessLauncherSpawnv                ,


-- ** takeFd #method:takeFd#
    SubprocessLauncherTakeFdMethodInfo      ,
    subprocessLauncherTakeFd                ,


-- ** takeStderrFd #method:takeStderrFd#
    SubprocessLauncherTakeStderrFdMethodInfo,
    subprocessLauncherTakeStderrFd          ,


-- ** takeStdinFd #method:takeStdinFd#
    SubprocessLauncherTakeStdinFdMethodInfo ,
    subprocessLauncherTakeStdinFd           ,


-- ** takeStdoutFd #method:takeStdoutFd#
    SubprocessLauncherTakeStdoutFdMethodInfo,
    subprocessLauncherTakeStdoutFd          ,


-- ** unsetenv #method:unsetenv#
    SubprocessLauncherUnsetenvMethodInfo    ,
    subprocessLauncherUnsetenv              ,




 -- * Properties
-- ** flags #attr:flags#
    SubprocessLauncherFlagsPropertyInfo     ,
    constructSubprocessLauncherFlags        ,
    subprocessLauncherFlags                 ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Objects.Subprocess as Gio.Subprocess

newtype SubprocessLauncher = SubprocessLauncher (ManagedPtr SubprocessLauncher)
foreign import ccall "g_subprocess_launcher_get_type"
    c_g_subprocess_launcher_get_type :: IO GType

instance GObject SubprocessLauncher where
    gobjectType _ = c_g_subprocess_launcher_get_type
    

class GObject o => IsSubprocessLauncher o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError SubprocessLauncher a) =>
    IsSubprocessLauncher a
#endif
instance IsSubprocessLauncher SubprocessLauncher
instance GObject.Object.IsObject SubprocessLauncher

toSubprocessLauncher :: IsSubprocessLauncher o => o -> IO SubprocessLauncher
toSubprocessLauncher = unsafeCastTo SubprocessLauncher

noSubprocessLauncher :: Maybe SubprocessLauncher
noSubprocessLauncher = Nothing

type family ResolveSubprocessLauncherMethod (t :: Symbol) (o :: *) :: * where
    ResolveSubprocessLauncherMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSubprocessLauncherMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSubprocessLauncherMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSubprocessLauncherMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSubprocessLauncherMethod "getenv" o = SubprocessLauncherGetenvMethodInfo
    ResolveSubprocessLauncherMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSubprocessLauncherMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSubprocessLauncherMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSubprocessLauncherMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSubprocessLauncherMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSubprocessLauncherMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveSubprocessLauncherMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveSubprocessLauncherMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSubprocessLauncherMethod "setenv" o = SubprocessLauncherSetenvMethodInfo
    ResolveSubprocessLauncherMethod "spawnv" o = SubprocessLauncherSpawnvMethodInfo
    ResolveSubprocessLauncherMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSubprocessLauncherMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSubprocessLauncherMethod "takeFd" o = SubprocessLauncherTakeFdMethodInfo
    ResolveSubprocessLauncherMethod "takeStderrFd" o = SubprocessLauncherTakeStderrFdMethodInfo
    ResolveSubprocessLauncherMethod "takeStdinFd" o = SubprocessLauncherTakeStdinFdMethodInfo
    ResolveSubprocessLauncherMethod "takeStdoutFd" o = SubprocessLauncherTakeStdoutFdMethodInfo
    ResolveSubprocessLauncherMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSubprocessLauncherMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSubprocessLauncherMethod "unsetenv" o = SubprocessLauncherUnsetenvMethodInfo
    ResolveSubprocessLauncherMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSubprocessLauncherMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSubprocessLauncherMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSubprocessLauncherMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSubprocessLauncherMethod "setChildSetup" o = SubprocessLauncherSetChildSetupMethodInfo
    ResolveSubprocessLauncherMethod "setCwd" o = SubprocessLauncherSetCwdMethodInfo
    ResolveSubprocessLauncherMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSubprocessLauncherMethod "setEnviron" o = SubprocessLauncherSetEnvironMethodInfo
    ResolveSubprocessLauncherMethod "setFlags" o = SubprocessLauncherSetFlagsMethodInfo
    ResolveSubprocessLauncherMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSubprocessLauncherMethod "setStderrFilePath" o = SubprocessLauncherSetStderrFilePathMethodInfo
    ResolveSubprocessLauncherMethod "setStdinFilePath" o = SubprocessLauncherSetStdinFilePathMethodInfo
    ResolveSubprocessLauncherMethod "setStdoutFilePath" o = SubprocessLauncherSetStdoutFilePathMethodInfo
    ResolveSubprocessLauncherMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSubprocessLauncherMethod t SubprocessLauncher, O.MethodInfo info SubprocessLauncher p) => O.IsLabelProxy t (SubprocessLauncher -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveSubprocessLauncherMethod t SubprocessLauncher, O.MethodInfo info SubprocessLauncher p) => O.IsLabel t (SubprocessLauncher -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "flags"
   -- Type: TInterface (Name {namespace = "Gio", name = "SubprocessFlags"})
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Just False)

constructSubprocessLauncherFlags :: (IsSubprocessLauncher o) => [Gio.Flags.SubprocessFlags] -> IO (GValueConstruct o)
constructSubprocessLauncherFlags val = constructObjectPropertyFlags "flags" val

data SubprocessLauncherFlagsPropertyInfo
instance AttrInfo SubprocessLauncherFlagsPropertyInfo where
    type AttrAllowedOps SubprocessLauncherFlagsPropertyInfo = '[ 'AttrConstruct]
    type AttrSetTypeConstraint SubprocessLauncherFlagsPropertyInfo = (~) [Gio.Flags.SubprocessFlags]
    type AttrBaseTypeConstraint SubprocessLauncherFlagsPropertyInfo = IsSubprocessLauncher
    type AttrGetType SubprocessLauncherFlagsPropertyInfo = ()
    type AttrLabel SubprocessLauncherFlagsPropertyInfo = "flags"
    type AttrOrigin SubprocessLauncherFlagsPropertyInfo = SubprocessLauncher
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructSubprocessLauncherFlags
    attrClear _ = undefined

instance O.HasAttributeList SubprocessLauncher
type instance O.AttributeList SubprocessLauncher = SubprocessLauncherAttributeList
type SubprocessLauncherAttributeList = ('[ '("flags", SubprocessLauncherFlagsPropertyInfo)] :: [(Symbol, *)])

subprocessLauncherFlags :: AttrLabelProxy "flags"
subprocessLauncherFlags = AttrLabelProxy

type instance O.SignalList SubprocessLauncher = SubprocessLauncherSignalList
type SubprocessLauncherSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method SubprocessLauncher::new
-- method type : Constructor
-- Args : [Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "SubprocessFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GSubprocessFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_new" g_subprocess_launcher_new :: 
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "SubprocessFlags"})
    IO (Ptr SubprocessLauncher)

{- |
Creates a new 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher'.

The launcher is created with the default options.  A copy of the
environment of the calling process is made at the time of this call
and will be used as the environment that the process is launched in.

@since 2.40
-}
subprocessLauncherNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Gio.Flags.SubprocessFlags]
    {- ^ /@flags@/: 'GI.Gio.Flags.SubprocessFlags' -}
    -> m SubprocessLauncher
subprocessLauncherNew flags = liftIO $ do
    let flags' = gflagsToWord flags
    result <- g_subprocess_launcher_new flags'
    checkUnexpectedReturnNULL "subprocessLauncherNew" result
    result' <- (wrapObject SubprocessLauncher) result
    return result'

-- method SubprocessLauncher::getenv
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "variable", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to get", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_getenv" g_subprocess_launcher_getenv :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CString ->                              -- variable : TBasicType TUTF8
    IO CString

{- |
Returns the value of the environment variable /@variable@/ in the
environment of processes launched from this launcher.

On UNIX, the returned string can be an arbitrary byte string.
On Windows, it will be UTF-8.

@since 2.40
-}
subprocessLauncherGetenv ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> T.Text
    {- ^ /@variable@/: the environment variable to get -}
    -> m T.Text
    {- ^ __Returns:__ the value of the environment variable, 'Nothing' if unset -}
subprocessLauncherGetenv self variable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    variable' <- textToCString variable
    result <- g_subprocess_launcher_getenv self' variable'
    checkUnexpectedReturnNULL "subprocessLauncherGetenv" result
    result' <- cstringToText result
    touchManagedPtr self
    freeMem variable'
    return result'

data SubprocessLauncherGetenvMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherGetenvMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherGetenv

-- method SubprocessLauncher::set_child_setup
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "child_setup", argType = TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSpawnChildSetupFunc to use as the child setup function", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 2, argDestroy = 3, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user data for @child_setup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy_notify", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDestroyNotify for @user_data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_set_child_setup" g_subprocess_launcher_set_child_setup :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    FunPtr GLib.Callbacks.C_SpawnChildSetupFunc -> -- child_setup : TInterface (Name {namespace = "GLib", name = "SpawnChildSetupFunc"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy_notify : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

{- |
Sets up a child setup function.

The child setup function will be called after @/fork()/@ but before
@/exec()/@ on the child\'s side.

/@destroyNotify@/ will not be automatically called on the child\'s side
of the @/fork()/@.  It will only be called when the last reference on the
'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' is dropped or when a new child setup function is
given.

'Nothing' can be given as /@childSetup@/ to disable the functionality.

Child setup functions are only available on UNIX.

@since 2.40
-}
subprocessLauncherSetChildSetup ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> GLib.Callbacks.SpawnChildSetupFunc
    {- ^ /@childSetup@/: a 'GI.GLib.Callbacks.SpawnChildSetupFunc' to use as the child setup function -}
    -> m ()
subprocessLauncherSetChildSetup self childSetup = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    childSetup' <- GLib.Callbacks.mk_SpawnChildSetupFunc (GLib.Callbacks.wrap_SpawnChildSetupFunc Nothing (GLib.Callbacks.drop_closures_SpawnChildSetupFunc childSetup))
    let userData = castFunPtrToPtr childSetup'
    let destroyNotify = safeFreeFunPtrPtr
    g_subprocess_launcher_set_child_setup self' childSetup' userData destroyNotify
    touchManagedPtr self
    return ()

data SubprocessLauncherSetChildSetupMethodInfo
instance (signature ~ (GLib.Callbacks.SpawnChildSetupFunc -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetChildSetupMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetChildSetup

-- method SubprocessLauncher::set_cwd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cwd", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the cwd for launched processes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_set_cwd" g_subprocess_launcher_set_cwd :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CString ->                              -- cwd : TBasicType TFileName
    IO ()

{- |
Sets the current working directory that processes will be launched
with.

By default processes are launched with the current working directory
of the launching process at the time of launch.

@since 2.40
-}
subprocessLauncherSetCwd ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> [Char]
    {- ^ /@cwd@/: the cwd for launched processes -}
    -> m ()
subprocessLauncherSetCwd self cwd = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    cwd' <- stringToCString cwd
    g_subprocess_launcher_set_cwd self' cwd'
    touchManagedPtr self
    freeMem cwd'
    return ()

data SubprocessLauncherSetCwdMethodInfo
instance (signature ~ ([Char] -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetCwdMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetCwd

-- method SubprocessLauncher::set_environ
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "env", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the replacement environment", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_set_environ" g_subprocess_launcher_set_environ :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    Ptr CString ->                          -- env : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()

{- |
Replace the entire environment of processes launched from this
launcher with the given \'environ\' variable.

Typically you will build this variable by using 'GI.GLib.Functions.listenv' to copy
the process \'environ\' and using the functions 'GI.GLib.Functions.environSetenv',
'GI.GLib.Functions.environUnsetenv', etc.

As an alternative, you can use 'GI.Gio.Objects.SubprocessLauncher.subprocessLauncherSetenv',
'GI.Gio.Objects.SubprocessLauncher.subprocessLauncherUnsetenv', etc.

On UNIX, all strings in this array can be arbitrary byte strings.
On Windows, they should be in UTF-8.

@since 2.40
-}
subprocessLauncherSetEnviron ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> [T.Text]
    {- ^ /@env@/: the replacement environment -}
    -> m ()
subprocessLauncherSetEnviron self env = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    env' <- packZeroTerminatedUTF8CArray env
    g_subprocess_launcher_set_environ self' env'
    touchManagedPtr self
    mapZeroTerminatedCArray freeMem env'
    freeMem env'
    return ()

data SubprocessLauncherSetEnvironMethodInfo
instance (signature ~ ([T.Text] -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetEnvironMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetEnviron

-- method SubprocessLauncher::set_flags
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "SubprocessFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GSubprocessFlags", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_set_flags" g_subprocess_launcher_set_flags :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "SubprocessFlags"})
    IO ()

{- |
Sets the flags on the launcher.

The default flags are 'GI.Gio.Flags.SubprocessFlagsNone'.

You may not set flags that specify conflicting options for how to
handle a particular stdio stream (eg: specifying both
'GI.Gio.Flags.SubprocessFlagsStdinPipe' and
'GI.Gio.Flags.SubprocessFlagsStdinInherit').

You may also not set a flag that conflicts with a previous call to a
function like 'GI.Gio.Objects.SubprocessLauncher.subprocessLauncherSetStdinFilePath' or
'GI.Gio.Objects.SubprocessLauncher.subprocessLauncherTakeStdoutFd'.

@since 2.40
-}
subprocessLauncherSetFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> [Gio.Flags.SubprocessFlags]
    {- ^ /@flags@/: 'GI.Gio.Flags.SubprocessFlags' -}
    -> m ()
subprocessLauncherSetFlags self flags = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    let flags' = gflagsToWord flags
    g_subprocess_launcher_set_flags self' flags'
    touchManagedPtr self
    return ()

data SubprocessLauncherSetFlagsMethodInfo
instance (signature ~ ([Gio.Flags.SubprocessFlags] -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetFlagsMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetFlags

-- method SubprocessLauncher::set_stderr_file_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a filename or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_set_stderr_file_path" g_subprocess_launcher_set_stderr_file_path :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CString ->                              -- path : TBasicType TFileName
    IO ()

{- |
Sets the file path to use as the stderr for spawned processes.

If /@path@/ is 'Nothing' then any previously given path is unset.

The file will be created or truncated when the process is spawned, as
would be the case if using \'2>\' at the shell.

If you want to send both stdout and stderr to the same file then use
'GI.Gio.Flags.SubprocessFlagsStderrMerge'.

You may not set a stderr file path if a stderr fd is already set or
if the launcher flags contain any flags directing stderr elsewhere.

This feature is only available on UNIX.

@since 2.40
-}
subprocessLauncherSetStderrFilePath ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> Maybe ([Char])
    {- ^ /@path@/: a filename or 'Nothing' -}
    -> m ()
subprocessLauncherSetStderrFilePath self path = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybePath <- case path of
        Nothing -> return nullPtr
        Just jPath -> do
            jPath' <- stringToCString jPath
            return jPath'
    g_subprocess_launcher_set_stderr_file_path self' maybePath
    touchManagedPtr self
    freeMem maybePath
    return ()

data SubprocessLauncherSetStderrFilePathMethodInfo
instance (signature ~ (Maybe ([Char]) -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetStderrFilePathMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetStderrFilePath

-- method SubprocessLauncher::set_stdin_file_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_set_stdin_file_path" g_subprocess_launcher_set_stdin_file_path :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CString ->                              -- path : TBasicType TUTF8
    IO ()

{- |
Sets the file path to use as the stdin for spawned processes.

If /@path@/ is 'Nothing' then any previously given path is unset.

The file must exist or spawning the process will fail.

You may not set a stdin file path if a stdin fd is already set or if
the launcher flags contain any flags directing stdin elsewhere.

This feature is only available on UNIX.

@since 2.40
-}
subprocessLauncherSetStdinFilePath ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> T.Text
    -> m ()
subprocessLauncherSetStdinFilePath self path = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    path' <- textToCString path
    g_subprocess_launcher_set_stdin_file_path self' path'
    touchManagedPtr self
    freeMem path'
    return ()

data SubprocessLauncherSetStdinFilePathMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetStdinFilePathMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetStdinFilePath

-- method SubprocessLauncher::set_stdout_file_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a filename or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_set_stdout_file_path" g_subprocess_launcher_set_stdout_file_path :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CString ->                              -- path : TBasicType TFileName
    IO ()

{- |
Sets the file path to use as the stdout for spawned processes.

If /@path@/ is 'Nothing' then any previously given path is unset.

The file will be created or truncated when the process is spawned, as
would be the case if using \'>\' at the shell.

You may not set a stdout file path if a stdout fd is already set or
if the launcher flags contain any flags directing stdout elsewhere.

This feature is only available on UNIX.

@since 2.40
-}
subprocessLauncherSetStdoutFilePath ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> Maybe ([Char])
    {- ^ /@path@/: a filename or 'Nothing' -}
    -> m ()
subprocessLauncherSetStdoutFilePath self path = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybePath <- case path of
        Nothing -> return nullPtr
        Just jPath -> do
            jPath' <- stringToCString jPath
            return jPath'
    g_subprocess_launcher_set_stdout_file_path self' maybePath
    touchManagedPtr self
    freeMem maybePath
    return ()

data SubprocessLauncherSetStdoutFilePathMethodInfo
instance (signature ~ (Maybe ([Char]) -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetStdoutFilePathMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetStdoutFilePath

-- method SubprocessLauncher::setenv
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "variable", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to set, must not contain '='", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new value for the variable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "overwrite", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to change the variable if it already exists", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_setenv" g_subprocess_launcher_setenv :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CString ->                              -- variable : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    CInt ->                                 -- overwrite : TBasicType TBoolean
    IO ()

{- |
Sets the environment variable /@variable@/ in the environment of
processes launched from this launcher.

On UNIX, both the variable\'s name and value can be arbitrary byte
strings, except that the variable\'s name cannot contain \'=\'.
On Windows, they should be in UTF-8.

@since 2.40
-}
subprocessLauncherSetenv ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> T.Text
    {- ^ /@variable@/: the environment variable to set, must not contain \'=\' -}
    -> T.Text
    {- ^ /@value@/: the new value for the variable -}
    -> Bool
    {- ^ /@overwrite@/: whether to change the variable if it already exists -}
    -> m ()
subprocessLauncherSetenv self variable value overwrite = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    variable' <- textToCString variable
    value' <- textToCString value
    let overwrite' = (fromIntegral . fromEnum) overwrite
    g_subprocess_launcher_setenv self' variable' value' overwrite'
    touchManagedPtr self
    freeMem variable'
    freeMem value'
    return ()

data SubprocessLauncherSetenvMethodInfo
instance (signature ~ (T.Text -> T.Text -> Bool -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSetenvMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSetenv

-- method SubprocessLauncher::spawnv
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argv", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Command line arguments", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "Subprocess"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_launcher_spawnv" g_subprocess_launcher_spawnv :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    Ptr CString ->                          -- argv : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Gio.Subprocess.Subprocess)

{- |
Creates a 'GI.Gio.Objects.Subprocess.Subprocess' given a provided array of arguments.

@since 2.40
-}
subprocessLauncherSpawnv ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> [T.Text]
    {- ^ /@argv@/: Command line arguments -}
    -> m Gio.Subprocess.Subprocess
    {- ^ __Returns:__ A new 'GI.Gio.Objects.Subprocess.Subprocess', or 'Nothing' on error (and /@error@/ will be set) /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessLauncherSpawnv self argv = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    argv' <- packZeroTerminatedUTF8CArray argv
    onException (do
        result <- propagateGError $ g_subprocess_launcher_spawnv self' argv'
        checkUnexpectedReturnNULL "subprocessLauncherSpawnv" result
        result' <- (wrapObject Gio.Subprocess.Subprocess) result
        touchManagedPtr self
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        return result'
     ) (do
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
     )

data SubprocessLauncherSpawnvMethodInfo
instance (signature ~ ([T.Text] -> m Gio.Subprocess.Subprocess), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherSpawnvMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherSpawnv

-- method SubprocessLauncher::take_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "source_fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "File descriptor in parent process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "target_fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Target descriptor for child process", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_take_fd" g_subprocess_launcher_take_fd :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    Int32 ->                                -- source_fd : TBasicType TInt
    Int32 ->                                -- target_fd : TBasicType TInt
    IO ()

{- |
Transfer an arbitrary file descriptor from parent process to the
child.  This function takes \"ownership\" of the fd; it will be closed
in the parent when /@self@/ is freed.

By default, all file descriptors from the parent will be closed.
This function allows you to create (for example) a custom @/pipe()/@ or
@/socketpair()/@ before launching the process, and choose the target
descriptor in the child.

An example use case is GNUPG, which has a command line argument
--passphrase-fd providing a file descriptor number where it expects
the passphrase to be written.
-}
subprocessLauncherTakeFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> Int32
    {- ^ /@sourceFd@/: File descriptor in parent process -}
    -> Int32
    {- ^ /@targetFd@/: Target descriptor for child process -}
    -> m ()
subprocessLauncherTakeFd self sourceFd targetFd = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    g_subprocess_launcher_take_fd self' sourceFd targetFd
    touchManagedPtr self
    return ()

data SubprocessLauncherTakeFdMethodInfo
instance (signature ~ (Int32 -> Int32 -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherTakeFdMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherTakeFd

-- method SubprocessLauncher::take_stderr_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor, or -1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_take_stderr_fd" g_subprocess_launcher_take_stderr_fd :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    Int32 ->                                -- fd : TBasicType TInt
    IO ()

{- |
Sets the file descriptor to use as the stderr for spawned processes.

If /@fd@/ is -1 then any previously given fd is unset.

Note that the default behaviour is to pass stderr through to the
stderr of the parent process.

The passed /@fd@/ belongs to the 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher'.  It will be
automatically closed when the launcher is finalized.  The file
descriptor will also be closed on the child side when executing the
spawned process.

You may not set a stderr fd if a stderr file path is already set or
if the launcher flags contain any flags directing stderr elsewhere.

This feature is only available on UNIX.

@since 2.40
-}
subprocessLauncherTakeStderrFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> Int32
    {- ^ /@fd@/: a file descriptor, or -1 -}
    -> m ()
subprocessLauncherTakeStderrFd self fd = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    g_subprocess_launcher_take_stderr_fd self' fd
    touchManagedPtr self
    return ()

data SubprocessLauncherTakeStderrFdMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherTakeStderrFdMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherTakeStderrFd

-- method SubprocessLauncher::take_stdin_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor, or -1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_take_stdin_fd" g_subprocess_launcher_take_stdin_fd :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    Int32 ->                                -- fd : TBasicType TInt
    IO ()

{- |
Sets the file descriptor to use as the stdin for spawned processes.

If /@fd@/ is -1 then any previously given fd is unset.

Note that if your intention is to have the stdin of the calling
process inherited by the child then 'GI.Gio.Flags.SubprocessFlagsStdinInherit'
is a better way to go about doing that.

The passed /@fd@/ is noted but will not be touched in the current
process.  It is therefore necessary that it be kept open by the
caller until the subprocess is spawned.  The file descriptor will
also not be explicitly closed on the child side, so it must be marked
O_CLOEXEC if that\'s what you want.

You may not set a stdin fd if a stdin file path is already set or if
the launcher flags contain any flags directing stdin elsewhere.

This feature is only available on UNIX.

@since 2.40
-}
subprocessLauncherTakeStdinFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> Int32
    {- ^ /@fd@/: a file descriptor, or -1 -}
    -> m ()
subprocessLauncherTakeStdinFd self fd = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    g_subprocess_launcher_take_stdin_fd self' fd
    touchManagedPtr self
    return ()

data SubprocessLauncherTakeStdinFdMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherTakeStdinFdMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherTakeStdinFd

-- method SubprocessLauncher::take_stdout_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocessLauncher", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a file descriptor, or -1", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_take_stdout_fd" g_subprocess_launcher_take_stdout_fd :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    Int32 ->                                -- fd : TBasicType TInt
    IO ()

{- |
Sets the file descriptor to use as the stdout for spawned processes.

If /@fd@/ is -1 then any previously given fd is unset.

Note that the default behaviour is to pass stdout through to the
stdout of the parent process.

The passed /@fd@/ is noted but will not be touched in the current
process.  It is therefore necessary that it be kept open by the
caller until the subprocess is spawned.  The file descriptor will
also not be explicitly closed on the child side, so it must be marked
O_CLOEXEC if that\'s what you want.

You may not set a stdout fd if a stdout file path is already set or
if the launcher flags contain any flags directing stdout elsewhere.

This feature is only available on UNIX.

@since 2.40
-}
subprocessLauncherTakeStdoutFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' -}
    -> Int32
    {- ^ /@fd@/: a file descriptor, or -1 -}
    -> m ()
subprocessLauncherTakeStdoutFd self fd = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    g_subprocess_launcher_take_stdout_fd self' fd
    touchManagedPtr self
    return ()

data SubprocessLauncherTakeStdoutFdMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherTakeStdoutFdMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherTakeStdoutFd

-- method SubprocessLauncher::unsetenv
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "variable", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to unset, must not contain '='", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_subprocess_launcher_unsetenv" g_subprocess_launcher_unsetenv :: 
    Ptr SubprocessLauncher ->               -- self : TInterface (Name {namespace = "Gio", name = "SubprocessLauncher"})
    CString ->                              -- variable : TBasicType TUTF8
    IO ()

{- |
Removes the environment variable /@variable@/ from the environment of
processes launched from this launcher.

On UNIX, the variable\'s name can be an arbitrary byte string not
containing \'=\'. On Windows, it should be in UTF-8.

@since 2.40
-}
subprocessLauncherUnsetenv ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocessLauncher a) =>
    a
    {- ^ /@self@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> T.Text
    {- ^ /@variable@/: the environment variable to unset, must not contain \'=\' -}
    -> m ()
subprocessLauncherUnsetenv self variable = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    variable' <- textToCString variable
    g_subprocess_launcher_unsetenv self' variable'
    touchManagedPtr self
    freeMem variable'
    return ()

data SubprocessLauncherUnsetenvMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsSubprocessLauncher a) => O.MethodInfo SubprocessLauncherUnsetenvMethodInfo a signature where
    overloadedMethod _ = subprocessLauncherUnsetenv