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

'GI.Gio.Objects.Subprocess.Subprocess' allows the creation of and interaction with child
processes.

Processes can be communicated with using standard GIO-style APIs (ie:
'GI.Gio.Objects.InputStream.InputStream', 'GI.Gio.Objects.OutputStream.OutputStream').  There are GIO-style APIs to wait for
process termination (ie: cancellable and with an asynchronous
variant).

There is an API to force a process to terminate, as well as a
race-free API for sending UNIX signals to a subprocess.

One major advantage that GIO brings over the core GLib library is
comprehensive API for asynchronous I\/O, such
'GI.Gio.Objects.OutputStream.outputStreamSpliceAsync'.  This makes GSubprocess
significantly more powerful and flexible than equivalent APIs in
some other languages such as the @subprocess.py@
included with Python.  For example, using 'GI.Gio.Objects.Subprocess.Subprocess' one could
create two child processes, reading standard output from the first,
processing it, and writing to the input stream of the second, all
without blocking the main loop.

A powerful 'GI.Gio.Objects.Subprocess.subprocessCommunicate' API is provided similar to the
@communicate()@ method of @subprocess.py@. This enables very easy
interaction with a subprocess that has been opened with pipes.

'GI.Gio.Objects.Subprocess.Subprocess' defaults to tight control over the file descriptors open
in the child process, avoiding dangling-fd issues that are caused by
a simple @/fork()/@\/@/exec()/@.  The only open file descriptors in the
spawned process are ones that were explicitly specified by the
'GI.Gio.Objects.Subprocess.Subprocess' API (unless 'GI.Gio.Flags.SubprocessFlagsInheritFds' was
specified).

'GI.Gio.Objects.Subprocess.Subprocess' will quickly reap all child processes as they exit,
avoiding \"zombie processes\" remaining around for long periods of
time.  'GI.Gio.Objects.Subprocess.subprocessWait' can be used to wait for this to happen,
but it will happen even without the call being explicitly made.

As a matter of principle, 'GI.Gio.Objects.Subprocess.Subprocess' has no API that accepts
shell-style space-separated strings.  It will, however, match the
typical shell behaviour of searching the PATH for executables that do
not contain a directory separator in their name.

'GI.Gio.Objects.Subprocess.Subprocess' attempts to have a very simple API for most uses (ie:
spawning a subprocess with arguments and support for most typical
kinds of input and output redirection).  See @/g_subprocess_new()/@. The
'GI.Gio.Objects.SubprocessLauncher.SubprocessLauncher' API is provided for more complicated cases
(advanced types of redirection, environment variable manipulation,
change of working directory, child setup functions, etc).

A typical use of 'GI.Gio.Objects.Subprocess.Subprocess' will involve calling
@/g_subprocess_new()/@, followed by 'GI.Gio.Objects.Subprocess.subprocessWaitAsync' or
'GI.Gio.Objects.Subprocess.subprocessWait'.  After the process exits, the status can be
checked using functions such as 'GI.Gio.Objects.Subprocess.subprocessGetIfExited' (which
are similar to the familiar WIFEXITED-style POSIX macros).

/Since: 2.40/
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Gio.Objects.Subprocess
    (

-- * Exported types
    Subprocess(..)                          ,
    IsSubprocess                            ,
    toSubprocess                            ,
    noSubprocess                            ,


 -- * Methods
-- ** communicate #method:communicate#

#if ENABLE_OVERLOADING
    SubprocessCommunicateMethodInfo         ,
#endif
    subprocessCommunicate                   ,


-- ** communicateAsync #method:communicateAsync#

#if ENABLE_OVERLOADING
    SubprocessCommunicateAsyncMethodInfo    ,
#endif
    subprocessCommunicateAsync              ,


-- ** communicateFinish #method:communicateFinish#

#if ENABLE_OVERLOADING
    SubprocessCommunicateFinishMethodInfo   ,
#endif
    subprocessCommunicateFinish             ,


-- ** communicateUtf8 #method:communicateUtf8#

#if ENABLE_OVERLOADING
    SubprocessCommunicateUtf8MethodInfo     ,
#endif
    subprocessCommunicateUtf8               ,


-- ** communicateUtf8Async #method:communicateUtf8Async#

#if ENABLE_OVERLOADING
    SubprocessCommunicateUtf8AsyncMethodInfo,
#endif
    subprocessCommunicateUtf8Async          ,


-- ** communicateUtf8Finish #method:communicateUtf8Finish#

#if ENABLE_OVERLOADING
    SubprocessCommunicateUtf8FinishMethodInfo,
#endif
    subprocessCommunicateUtf8Finish         ,


-- ** forceExit #method:forceExit#

#if ENABLE_OVERLOADING
    SubprocessForceExitMethodInfo           ,
#endif
    subprocessForceExit                     ,


-- ** getExitStatus #method:getExitStatus#

#if ENABLE_OVERLOADING
    SubprocessGetExitStatusMethodInfo       ,
#endif
    subprocessGetExitStatus                 ,


-- ** getIdentifier #method:getIdentifier#

#if ENABLE_OVERLOADING
    SubprocessGetIdentifierMethodInfo       ,
#endif
    subprocessGetIdentifier                 ,


-- ** getIfExited #method:getIfExited#

#if ENABLE_OVERLOADING
    SubprocessGetIfExitedMethodInfo         ,
#endif
    subprocessGetIfExited                   ,


-- ** getIfSignaled #method:getIfSignaled#

#if ENABLE_OVERLOADING
    SubprocessGetIfSignaledMethodInfo       ,
#endif
    subprocessGetIfSignaled                 ,


-- ** getStatus #method:getStatus#

#if ENABLE_OVERLOADING
    SubprocessGetStatusMethodInfo           ,
#endif
    subprocessGetStatus                     ,


-- ** getStderrPipe #method:getStderrPipe#

#if ENABLE_OVERLOADING
    SubprocessGetStderrPipeMethodInfo       ,
#endif
    subprocessGetStderrPipe                 ,


-- ** getStdinPipe #method:getStdinPipe#

#if ENABLE_OVERLOADING
    SubprocessGetStdinPipeMethodInfo        ,
#endif
    subprocessGetStdinPipe                  ,


-- ** getStdoutPipe #method:getStdoutPipe#

#if ENABLE_OVERLOADING
    SubprocessGetStdoutPipeMethodInfo       ,
#endif
    subprocessGetStdoutPipe                 ,


-- ** getSuccessful #method:getSuccessful#

#if ENABLE_OVERLOADING
    SubprocessGetSuccessfulMethodInfo       ,
#endif
    subprocessGetSuccessful                 ,


-- ** getTermSig #method:getTermSig#

#if ENABLE_OVERLOADING
    SubprocessGetTermSigMethodInfo          ,
#endif
    subprocessGetTermSig                    ,


-- ** new #method:new#

    subprocessNew                           ,


-- ** sendSignal #method:sendSignal#

#if ENABLE_OVERLOADING
    SubprocessSendSignalMethodInfo          ,
#endif
    subprocessSendSignal                    ,


-- ** wait #method:wait#

#if ENABLE_OVERLOADING
    SubprocessWaitMethodInfo                ,
#endif
    subprocessWait                          ,


-- ** waitAsync #method:waitAsync#

#if ENABLE_OVERLOADING
    SubprocessWaitAsyncMethodInfo           ,
#endif
    subprocessWaitAsync                     ,


-- ** waitCheck #method:waitCheck#

#if ENABLE_OVERLOADING
    SubprocessWaitCheckMethodInfo           ,
#endif
    subprocessWaitCheck                     ,


-- ** waitCheckAsync #method:waitCheckAsync#

#if ENABLE_OVERLOADING
    SubprocessWaitCheckAsyncMethodInfo      ,
#endif
    subprocessWaitCheckAsync                ,


-- ** waitCheckFinish #method:waitCheckFinish#

#if ENABLE_OVERLOADING
    SubprocessWaitCheckFinishMethodInfo     ,
#endif
    subprocessWaitCheckFinish               ,


-- ** waitFinish #method:waitFinish#

#if ENABLE_OVERLOADING
    SubprocessWaitFinishMethodInfo          ,
#endif
    subprocessWaitFinish                    ,




 -- * Properties
-- ** argv #attr:argv#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    SubprocessArgvPropertyInfo              ,
#endif
    constructSubprocessArgv                 ,
#if ENABLE_OVERLOADING
    subprocessArgv                          ,
#endif


-- ** flags #attr:flags#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    SubprocessFlagsPropertyInfo             ,
#endif
    constructSubprocessFlags                ,
#if ENABLE_OVERLOADING
    subprocessFlags                         ,
#endif




    ) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
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 GHC.OverloadedLabels as OL

import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Initable as Gio.Initable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream
import {-# SOURCE #-} qualified GI.Gio.Objects.OutputStream as Gio.OutputStream

-- | Memory-managed wrapper type.
newtype Subprocess = Subprocess (ManagedPtr Subprocess)
foreign import ccall "g_subprocess_get_type"
    c_g_subprocess_get_type :: IO GType

instance GObject Subprocess where
    gobjectType = c_g_subprocess_get_type


-- | Type class for types which can be safely cast to `Subprocess`, for instance with `toSubprocess`.
class (GObject o, O.IsDescendantOf Subprocess o) => IsSubprocess o
instance (GObject o, O.IsDescendantOf Subprocess o) => IsSubprocess o

instance O.HasParentTypes Subprocess
type instance O.ParentTypes Subprocess = '[GObject.Object.Object, Gio.Initable.Initable]

-- | Cast to `Subprocess`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toSubprocess :: (MonadIO m, IsSubprocess o) => o -> m Subprocess
toSubprocess = liftIO . unsafeCastTo Subprocess

-- | A convenience alias for `Nothing` :: `Maybe` `Subprocess`.
noSubprocess :: Maybe Subprocess
noSubprocess = Nothing

#if ENABLE_OVERLOADING
type family ResolveSubprocessMethod (t :: Symbol) (o :: *) :: * where
    ResolveSubprocessMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveSubprocessMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveSubprocessMethod "communicate" o = SubprocessCommunicateMethodInfo
    ResolveSubprocessMethod "communicateAsync" o = SubprocessCommunicateAsyncMethodInfo
    ResolveSubprocessMethod "communicateFinish" o = SubprocessCommunicateFinishMethodInfo
    ResolveSubprocessMethod "communicateUtf8" o = SubprocessCommunicateUtf8MethodInfo
    ResolveSubprocessMethod "communicateUtf8Async" o = SubprocessCommunicateUtf8AsyncMethodInfo
    ResolveSubprocessMethod "communicateUtf8Finish" o = SubprocessCommunicateUtf8FinishMethodInfo
    ResolveSubprocessMethod "forceExit" o = SubprocessForceExitMethodInfo
    ResolveSubprocessMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveSubprocessMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveSubprocessMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveSubprocessMethod "init" o = Gio.Initable.InitableInitMethodInfo
    ResolveSubprocessMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveSubprocessMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveSubprocessMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveSubprocessMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveSubprocessMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveSubprocessMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveSubprocessMethod "sendSignal" o = SubprocessSendSignalMethodInfo
    ResolveSubprocessMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveSubprocessMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveSubprocessMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveSubprocessMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveSubprocessMethod "wait" o = SubprocessWaitMethodInfo
    ResolveSubprocessMethod "waitAsync" o = SubprocessWaitAsyncMethodInfo
    ResolveSubprocessMethod "waitCheck" o = SubprocessWaitCheckMethodInfo
    ResolveSubprocessMethod "waitCheckAsync" o = SubprocessWaitCheckAsyncMethodInfo
    ResolveSubprocessMethod "waitCheckFinish" o = SubprocessWaitCheckFinishMethodInfo
    ResolveSubprocessMethod "waitFinish" o = SubprocessWaitFinishMethodInfo
    ResolveSubprocessMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveSubprocessMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveSubprocessMethod "getExitStatus" o = SubprocessGetExitStatusMethodInfo
    ResolveSubprocessMethod "getIdentifier" o = SubprocessGetIdentifierMethodInfo
    ResolveSubprocessMethod "getIfExited" o = SubprocessGetIfExitedMethodInfo
    ResolveSubprocessMethod "getIfSignaled" o = SubprocessGetIfSignaledMethodInfo
    ResolveSubprocessMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveSubprocessMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveSubprocessMethod "getStatus" o = SubprocessGetStatusMethodInfo
    ResolveSubprocessMethod "getStderrPipe" o = SubprocessGetStderrPipeMethodInfo
    ResolveSubprocessMethod "getStdinPipe" o = SubprocessGetStdinPipeMethodInfo
    ResolveSubprocessMethod "getStdoutPipe" o = SubprocessGetStdoutPipeMethodInfo
    ResolveSubprocessMethod "getSuccessful" o = SubprocessGetSuccessfulMethodInfo
    ResolveSubprocessMethod "getTermSig" o = SubprocessGetTermSigMethodInfo
    ResolveSubprocessMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveSubprocessMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveSubprocessMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveSubprocessMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveSubprocessMethod t Subprocess, O.MethodInfo info Subprocess p) => OL.IsLabel t (Subprocess -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

-- VVV Prop "argv"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Construct a `GValueConstruct` with valid value for the “@argv@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSubprocessArgv :: (IsSubprocess o) => [T.Text] -> IO (GValueConstruct o)
constructSubprocessArgv val = B.Properties.constructObjectPropertyStringArray "argv" (Just val)

#if ENABLE_OVERLOADING
data SubprocessArgvPropertyInfo
instance AttrInfo SubprocessArgvPropertyInfo where
    type AttrAllowedOps SubprocessArgvPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrSetTypeConstraint SubprocessArgvPropertyInfo = (~) [T.Text]
    type AttrBaseTypeConstraint SubprocessArgvPropertyInfo = IsSubprocess
    type AttrGetType SubprocessArgvPropertyInfo = ()
    type AttrLabel SubprocessArgvPropertyInfo = "argv"
    type AttrOrigin SubprocessArgvPropertyInfo = Subprocess
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructSubprocessArgv
    attrClear _ = undefined
#endif

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

{- |
Construct a `GValueConstruct` with valid value for the “@flags@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructSubprocessFlags :: (IsSubprocess o) => [Gio.Flags.SubprocessFlags] -> IO (GValueConstruct o)
constructSubprocessFlags val = B.Properties.constructObjectPropertyFlags "flags" val

#if ENABLE_OVERLOADING
data SubprocessFlagsPropertyInfo
instance AttrInfo SubprocessFlagsPropertyInfo where
    type AttrAllowedOps SubprocessFlagsPropertyInfo = '[ 'AttrConstruct]
    type AttrSetTypeConstraint SubprocessFlagsPropertyInfo = (~) [Gio.Flags.SubprocessFlags]
    type AttrBaseTypeConstraint SubprocessFlagsPropertyInfo = IsSubprocess
    type AttrGetType SubprocessFlagsPropertyInfo = ()
    type AttrLabel SubprocessFlagsPropertyInfo = "flags"
    type AttrOrigin SubprocessFlagsPropertyInfo = Subprocess
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructSubprocessFlags
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Subprocess
type instance O.AttributeList Subprocess = SubprocessAttributeList
type SubprocessAttributeList = ('[ '("argv", SubprocessArgvPropertyInfo), '("flags", SubprocessFlagsPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
subprocessArgv :: AttrLabelProxy "argv"
subprocessArgv = AttrLabelProxy

subprocessFlags :: AttrLabelProxy "flags"
subprocessFlags = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Subprocess = SubprocessSignalList
type SubprocessSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Subprocess::new
-- method type : Constructor
-- Args : [Arg {argCName = "argv", argType = TCArray True (-1) (-1) (TBasicType TFileName), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "commandline arguments for the subprocess", 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 "flags that define the behaviour of the subprocess", 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_newv" g_subprocess_newv ::
    Ptr CString ->                          -- argv : TCArray True (-1) (-1) (TBasicType TFileName)
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "SubprocessFlags"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Subprocess)

{- |
Create a new process with the given flags and argument list.

The argument list is expected to be 'Nothing'-terminated.

/Since: 2.40/
-}
subprocessNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [[Char]]
    {- ^ /@argv@/: commandline arguments for the subprocess -}
    -> [Gio.Flags.SubprocessFlags]
    {- ^ /@flags@/: flags that define the behaviour of the subprocess -}
    -> m Subprocess
    {- ^ __Returns:__ A newly created 'GI.Gio.Objects.Subprocess.Subprocess', or 'Nothing' on error (and /@error@/
  will be set) /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessNew argv flags = liftIO $ do
    argv' <- packZeroTerminatedFileNameArray argv
    let flags' = gflagsToWord flags
    onException (do
        result <- propagateGError $ g_subprocess_newv argv' flags'
        checkUnexpectedReturnNULL "subprocessNew" result
        result' <- (wrapObject Subprocess) result
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
        return result'
     ) (do
        mapZeroTerminatedCArray freeMem argv'
        freeMem argv'
     )

#if ENABLE_OVERLOADING
#endif

-- method Subprocess::communicate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdin_buf", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to send to the stdin of the subprocess, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdout_buf", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data read from the subprocess stdout", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "stderr_buf", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data read from the subprocess stderr", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_communicate" g_subprocess_communicate ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr GLib.Bytes.Bytes ->                 -- stdin_buf : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GLib.Bytes.Bytes) ->           -- stdout_buf : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr (Ptr GLib.Bytes.Bytes) ->           -- stderr_buf : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Communicate with the subprocess until it terminates, and all input
and output has been completed.

If /@stdinBuf@/ is given, the subprocess must have been created with
'GI.Gio.Flags.SubprocessFlagsStdinPipe'.  The given data is fed to the
stdin of the subprocess and the pipe is closed (ie: EOF).

At the same time (as not to cause blocking when dealing with large
amounts of data), if 'GI.Gio.Flags.SubprocessFlagsStdoutPipe' or
'GI.Gio.Flags.SubprocessFlagsStderrPipe' were used, reads from those
streams.  The data that was read is returned in /@stdout@/ and\/or
the /@stderr@/.

If the subprocess was created with 'GI.Gio.Flags.SubprocessFlagsStdoutPipe',
/@stdoutBuf@/ will contain the data read from stdout.  Otherwise, for
subprocesses not created with 'GI.Gio.Flags.SubprocessFlagsStdoutPipe',
/@stdoutBuf@/ will be set to 'Nothing'.  Similar provisions apply to
/@stderrBuf@/ and 'GI.Gio.Flags.SubprocessFlagsStderrPipe'.

As usual, any output variable may be given as 'Nothing' to ignore it.

If you desire the stdout and stderr data to be interleaved, create
the subprocess with 'GI.Gio.Flags.SubprocessFlagsStdoutPipe' and
'GI.Gio.Flags.SubprocessFlagsStderrMerge'.  The merged result will be returned
in /@stdoutBuf@/ and /@stderrBuf@/ will be set to 'Nothing'.

In case of any error (including cancellation), 'False' will be
returned with /@error@/ set.  Some or all of the stdin data may have
been written.  Any stdout or stderr data that has been read will be
discarded. None of the out variables (aside from /@error@/) will have
been set to anything in particular and should not be inspected.

In the case that 'True' is returned, the subprocess has exited and the
exit status inspection APIs (eg: 'GI.Gio.Objects.Subprocess.subprocessGetIfExited',
'GI.Gio.Objects.Subprocess.subprocessGetExitStatus') may be used.

You should not attempt to use any of the subprocess pipes after
starting this function, since they may be left in strange states,
even if the operation was cancelled.  You should especially not
attempt to interact with the pipes while the operation is in progress
(either from another thread or if using the asynchronous version).

/Since: 2.40/
-}
subprocessCommunicate ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> Maybe (GLib.Bytes.Bytes)
    {- ^ /@stdinBuf@/: data to send to the stdin of the subprocess, or 'Nothing' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
    -> m ((Maybe GLib.Bytes.Bytes, Maybe GLib.Bytes.Bytes))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessCommunicate subprocess stdinBuf cancellable = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeStdinBuf <- case stdinBuf of
        Nothing -> return nullPtr
        Just jStdinBuf -> do
            jStdinBuf' <- unsafeManagedPtrGetPtr jStdinBuf
            return jStdinBuf'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    stdoutBuf <- allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    stderrBuf <- allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    onException (do
        _ <- propagateGError $ g_subprocess_communicate subprocess' maybeStdinBuf maybeCancellable stdoutBuf stderrBuf
        stdoutBuf' <- peek stdoutBuf
        maybeStdoutBuf' <- convertIfNonNull stdoutBuf' $ \stdoutBuf'' -> do
            stdoutBuf''' <- (wrapBoxed GLib.Bytes.Bytes) stdoutBuf''
            return stdoutBuf'''
        stderrBuf' <- peek stderrBuf
        maybeStderrBuf' <- convertIfNonNull stderrBuf' $ \stderrBuf'' -> do
            stderrBuf''' <- (wrapBoxed GLib.Bytes.Bytes) stderrBuf''
            return stderrBuf'''
        touchManagedPtr subprocess
        whenJust stdinBuf touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem stdoutBuf
        freeMem stderrBuf
        return (maybeStdoutBuf', maybeStderrBuf')
     ) (do
        freeMem stdoutBuf
        freeMem stderrBuf
     )

#if ENABLE_OVERLOADING
data SubprocessCommunicateMethodInfo
instance (signature ~ (Maybe (GLib.Bytes.Bytes) -> Maybe (b) -> m ((Maybe GLib.Bytes.Bytes, Maybe GLib.Bytes.Bytes))), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessCommunicateMethodInfo a signature where
    overloadedMethod _ = subprocessCommunicate

#endif

-- method Subprocess::communicate_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdin_buf", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Input data, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Callback", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data", 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_communicate_async" g_subprocess_communicate_async ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr GLib.Bytes.Bytes ->                 -- stdin_buf : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronous version of 'GI.Gio.Objects.Subprocess.subprocessCommunicate'.  Complete
invocation with 'GI.Gio.Objects.Subprocess.subprocessCommunicateFinish'.
-}
subprocessCommunicateAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: Self -}
    -> Maybe (GLib.Bytes.Bytes)
    {- ^ /@stdinBuf@/: Input data, or 'Nothing' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: Callback -}
    -> m ()
subprocessCommunicateAsync subprocess stdinBuf cancellable callback = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeStdinBuf <- case stdinBuf of
        Nothing -> return nullPtr
        Just jStdinBuf -> do
            jStdinBuf' <- unsafeManagedPtrGetPtr jStdinBuf
            return jStdinBuf'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_subprocess_communicate_async subprocess' maybeStdinBuf maybeCancellable maybeCallback userData
    touchManagedPtr subprocess
    whenJust stdinBuf touchManagedPtr
    whenJust cancellable touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data SubprocessCommunicateAsyncMethodInfo
instance (signature ~ (Maybe (GLib.Bytes.Bytes) -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessCommunicateAsyncMethodInfo a signature where
    overloadedMethod _ = subprocessCommunicateAsync

#endif

-- method Subprocess::communicate_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdout_buf", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Return location for stdout data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "stderr_buf", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Return location for stderr data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_communicate_finish" g_subprocess_communicate_finish ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GLib.Bytes.Bytes) ->           -- stdout_buf : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr (Ptr GLib.Bytes.Bytes) ->           -- stderr_buf : TInterface (Name {namespace = "GLib", name = "Bytes"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Complete an invocation of 'GI.Gio.Objects.Subprocess.subprocessCommunicateAsync'.
-}
subprocessCommunicateFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@subprocess@/: Self -}
    -> b
    {- ^ /@result@/: Result -}
    -> m ((Maybe GLib.Bytes.Bytes, Maybe GLib.Bytes.Bytes))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessCommunicateFinish subprocess result_ = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result_' <- unsafeManagedPtrCastPtr result_
    stdoutBuf <- allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    stderrBuf <- allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    onException (do
        _ <- propagateGError $ g_subprocess_communicate_finish subprocess' result_' stdoutBuf stderrBuf
        stdoutBuf' <- peek stdoutBuf
        maybeStdoutBuf' <- convertIfNonNull stdoutBuf' $ \stdoutBuf'' -> do
            stdoutBuf''' <- (wrapBoxed GLib.Bytes.Bytes) stdoutBuf''
            return stdoutBuf'''
        stderrBuf' <- peek stderrBuf
        maybeStderrBuf' <- convertIfNonNull stderrBuf' $ \stderrBuf'' -> do
            stderrBuf''' <- (wrapBoxed GLib.Bytes.Bytes) stderrBuf''
            return stderrBuf'''
        touchManagedPtr subprocess
        touchManagedPtr result_
        freeMem stdoutBuf
        freeMem stderrBuf
        return (maybeStdoutBuf', maybeStderrBuf')
     ) (do
        freeMem stdoutBuf
        freeMem stderrBuf
     )

#if ENABLE_OVERLOADING
data SubprocessCommunicateFinishMethodInfo
instance (signature ~ (b -> m ((Maybe GLib.Bytes.Bytes, Maybe GLib.Bytes.Bytes))), MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SubprocessCommunicateFinishMethodInfo a signature where
    overloadedMethod _ = subprocessCommunicateFinish

#endif

-- method Subprocess::communicate_utf8
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdin_buf", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data to send to the stdin of the subprocess, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdout_buf", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data read from the subprocess stdout", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "stderr_buf", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data read from the subprocess stderr", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_communicate_utf8" g_subprocess_communicate_utf8 ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    CString ->                              -- stdin_buf : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr CString ->                          -- stdout_buf : TBasicType TUTF8
    Ptr CString ->                          -- stderr_buf : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Like 'GI.Gio.Objects.Subprocess.subprocessCommunicate', but validates the output of the
process as UTF-8, and returns it as a regular NUL terminated string.

On error, /@stdoutBuf@/ and /@stderrBuf@/ will be set to undefined values and
should not be used.
-}
subprocessCommunicateUtf8 ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> Maybe (T.Text)
    {- ^ /@stdinBuf@/: data to send to the stdin of the subprocess, or 'Nothing' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
    -> m ((Maybe T.Text, Maybe T.Text))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessCommunicateUtf8 subprocess stdinBuf cancellable = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeStdinBuf <- case stdinBuf of
        Nothing -> return nullPtr
        Just jStdinBuf -> do
            jStdinBuf' <- textToCString jStdinBuf
            return jStdinBuf'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    stdoutBuf <- allocMem :: IO (Ptr CString)
    stderrBuf <- allocMem :: IO (Ptr CString)
    onException (do
        _ <- propagateGError $ g_subprocess_communicate_utf8 subprocess' maybeStdinBuf maybeCancellable stdoutBuf stderrBuf
        stdoutBuf' <- peek stdoutBuf
        maybeStdoutBuf' <- convertIfNonNull stdoutBuf' $ \stdoutBuf'' -> do
            stdoutBuf''' <- cstringToText stdoutBuf''
            return stdoutBuf'''
        freeMem stdoutBuf'
        stderrBuf' <- peek stderrBuf
        maybeStderrBuf' <- convertIfNonNull stderrBuf' $ \stderrBuf'' -> do
            stderrBuf''' <- cstringToText stderrBuf''
            return stderrBuf'''
        freeMem stderrBuf'
        touchManagedPtr subprocess
        whenJust cancellable touchManagedPtr
        freeMem maybeStdinBuf
        freeMem stdoutBuf
        freeMem stderrBuf
        return (maybeStdoutBuf', maybeStderrBuf')
     ) (do
        freeMem maybeStdinBuf
        freeMem stdoutBuf
        freeMem stderrBuf
     )

#if ENABLE_OVERLOADING
data SubprocessCommunicateUtf8MethodInfo
instance (signature ~ (Maybe (T.Text) -> Maybe (b) -> m ((Maybe T.Text, Maybe T.Text))), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessCommunicateUtf8MethodInfo a signature where
    overloadedMethod _ = subprocessCommunicateUtf8

#endif

-- method Subprocess::communicate_utf8_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdin_buf", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Input data, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Cancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Callback", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data", 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_communicate_utf8_async" g_subprocess_communicate_utf8_async ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    CString ->                              -- stdin_buf : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronous version of 'GI.Gio.Objects.Subprocess.subprocessCommunicateUtf8'.  Complete
invocation with 'GI.Gio.Objects.Subprocess.subprocessCommunicateUtf8Finish'.
-}
subprocessCommunicateUtf8Async ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: Self -}
    -> Maybe (T.Text)
    {- ^ /@stdinBuf@/: Input data, or 'Nothing' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: Cancellable -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: Callback -}
    -> m ()
subprocessCommunicateUtf8Async subprocess stdinBuf cancellable callback = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeStdinBuf <- case stdinBuf of
        Nothing -> return nullPtr
        Just jStdinBuf -> do
            jStdinBuf' <- textToCString jStdinBuf
            return jStdinBuf'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_subprocess_communicate_utf8_async subprocess' maybeStdinBuf maybeCancellable maybeCallback userData
    touchManagedPtr subprocess
    whenJust cancellable touchManagedPtr
    freeMem maybeStdinBuf
    return ()

#if ENABLE_OVERLOADING
data SubprocessCommunicateUtf8AsyncMethodInfo
instance (signature ~ (Maybe (T.Text) -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessCommunicateUtf8AsyncMethodInfo a signature where
    overloadedMethod _ = subprocessCommunicateUtf8Async

#endif

-- method Subprocess::communicate_utf8_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Self", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Result", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stdout_buf", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Return location for stdout data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "stderr_buf", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Return location for stderr data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_communicate_utf8_finish" g_subprocess_communicate_utf8_finish ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr CString ->                          -- stdout_buf : TBasicType TUTF8
    Ptr CString ->                          -- stderr_buf : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Complete an invocation of 'GI.Gio.Objects.Subprocess.subprocessCommunicateUtf8Async'.
-}
subprocessCommunicateUtf8Finish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@subprocess@/: Self -}
    -> b
    {- ^ /@result@/: Result -}
    -> m ((Maybe T.Text, Maybe T.Text))
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessCommunicateUtf8Finish subprocess result_ = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result_' <- unsafeManagedPtrCastPtr result_
    stdoutBuf <- allocMem :: IO (Ptr CString)
    stderrBuf <- allocMem :: IO (Ptr CString)
    onException (do
        _ <- propagateGError $ g_subprocess_communicate_utf8_finish subprocess' result_' stdoutBuf stderrBuf
        stdoutBuf' <- peek stdoutBuf
        maybeStdoutBuf' <- convertIfNonNull stdoutBuf' $ \stdoutBuf'' -> do
            stdoutBuf''' <- cstringToText stdoutBuf''
            return stdoutBuf'''
        freeMem stdoutBuf'
        stderrBuf' <- peek stderrBuf
        maybeStderrBuf' <- convertIfNonNull stderrBuf' $ \stderrBuf'' -> do
            stderrBuf''' <- cstringToText stderrBuf''
            return stderrBuf'''
        freeMem stderrBuf'
        touchManagedPtr subprocess
        touchManagedPtr result_
        freeMem stdoutBuf
        freeMem stderrBuf
        return (maybeStdoutBuf', maybeStderrBuf')
     ) (do
        freeMem stdoutBuf
        freeMem stderrBuf
     )

#if ENABLE_OVERLOADING
data SubprocessCommunicateUtf8FinishMethodInfo
instance (signature ~ (b -> m ((Maybe T.Text, Maybe T.Text))), MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SubprocessCommunicateUtf8FinishMethodInfo a signature where
    overloadedMethod _ = subprocessCommunicateUtf8Finish

#endif

-- method Subprocess::force_exit
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", 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_force_exit" g_subprocess_force_exit ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO ()

{- |
Use an operating-system specific method to attempt an immediate,
forceful termination of the process.  There is no mechanism to
determine whether or not the request itself was successful;
however, you can use 'GI.Gio.Objects.Subprocess.subprocessWait' to monitor the status of
the process after calling this function.

On Unix, this function sends @/SIGKILL/@.

/Since: 2.40/
-}
subprocessForceExit ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m ()
subprocessForceExit subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    g_subprocess_force_exit subprocess'
    touchManagedPtr subprocess
    return ()

#if ENABLE_OVERLOADING
data SubprocessForceExitMethodInfo
instance (signature ~ (m ()), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessForceExitMethodInfo a signature where
    overloadedMethod _ = subprocessForceExit

#endif

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

foreign import ccall "g_subprocess_get_exit_status" g_subprocess_get_exit_status ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO Int32

{- |
Check the exit status of the subprocess, given that it exited
normally.  This is the value passed to the @/exit()/@ system call or the
return value from main.

This is equivalent to the system WEXITSTATUS macro.

It is an error to call this function before 'GI.Gio.Objects.Subprocess.subprocessWait' and
unless 'GI.Gio.Objects.Subprocess.subprocessGetIfExited' returned 'True'.

/Since: 2.40/
-}
subprocessGetExitStatus ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Int32
    {- ^ __Returns:__ the exit status -}
subprocessGetExitStatus subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_exit_status subprocess'
    touchManagedPtr subprocess
    return result

#if ENABLE_OVERLOADING
data SubprocessGetExitStatusMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetExitStatusMethodInfo a signature where
    overloadedMethod _ = subprocessGetExitStatus

#endif

-- method Subprocess::get_identifier
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", 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_get_identifier" g_subprocess_get_identifier ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO CString

{- |
On UNIX, returns the process ID as a decimal string.
On Windows, returns the result of @/GetProcessId()/@ also as a string.
-}
subprocessGetIdentifier ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m T.Text
subprocessGetIdentifier subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_identifier subprocess'
    checkUnexpectedReturnNULL "subprocessGetIdentifier" result
    result' <- cstringToText result
    touchManagedPtr subprocess
    return result'

#if ENABLE_OVERLOADING
data SubprocessGetIdentifierMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetIdentifierMethodInfo a signature where
    overloadedMethod _ = subprocessGetIdentifier

#endif

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

foreign import ccall "g_subprocess_get_if_exited" g_subprocess_get_if_exited ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO CInt

{- |
Check if the given subprocess exited normally (ie: by way of @/exit()/@
or return from @/main()/@).

This is equivalent to the system WIFEXITED macro.

It is an error to call this function before 'GI.Gio.Objects.Subprocess.subprocessWait' has
returned.

/Since: 2.40/
-}
subprocessGetIfExited ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the case of a normal exit -}
subprocessGetIfExited subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_if_exited subprocess'
    let result' = (/= 0) result
    touchManagedPtr subprocess
    return result'

#if ENABLE_OVERLOADING
data SubprocessGetIfExitedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetIfExitedMethodInfo a signature where
    overloadedMethod _ = subprocessGetIfExited

#endif

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

foreign import ccall "g_subprocess_get_if_signaled" g_subprocess_get_if_signaled ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO CInt

{- |
Check if the given subprocess terminated in response to a signal.

This is equivalent to the system WIFSIGNALED macro.

It is an error to call this function before 'GI.Gio.Objects.Subprocess.subprocessWait' has
returned.

/Since: 2.40/
-}
subprocessGetIfSignaled ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the case of termination due to a signal -}
subprocessGetIfSignaled subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_if_signaled subprocess'
    let result' = (/= 0) result
    touchManagedPtr subprocess
    return result'

#if ENABLE_OVERLOADING
data SubprocessGetIfSignaledMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetIfSignaledMethodInfo a signature where
    overloadedMethod _ = subprocessGetIfSignaled

#endif

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

foreign import ccall "g_subprocess_get_status" g_subprocess_get_status ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO Int32

{- |
Gets the raw status code of the process, as from @/waitpid()/@.

This value has no particular meaning, but it can be used with the
macros defined by the system headers such as WIFEXITED.  It can also
be used with 'GI.GLib.Functions.spawnCheckExitStatus'.

It is more likely that you want to use 'GI.Gio.Objects.Subprocess.subprocessGetIfExited'
followed by 'GI.Gio.Objects.Subprocess.subprocessGetExitStatus'.

It is an error to call this function before 'GI.Gio.Objects.Subprocess.subprocessWait' has
returned.

/Since: 2.40/
-}
subprocessGetStatus ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Int32
    {- ^ __Returns:__ the (meaningless) @/waitpid()/@ exit status from the kernel -}
subprocessGetStatus subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_status subprocess'
    touchManagedPtr subprocess
    return result

#if ENABLE_OVERLOADING
data SubprocessGetStatusMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetStatusMethodInfo a signature where
    overloadedMethod _ = subprocessGetStatus

#endif

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

foreign import ccall "g_subprocess_get_stderr_pipe" g_subprocess_get_stderr_pipe ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO (Ptr Gio.InputStream.InputStream)

{- |
Gets the 'GI.Gio.Objects.InputStream.InputStream' from which to read the stderr output of
/@subprocess@/.

The process must have been created with
'GI.Gio.Flags.SubprocessFlagsStderrPipe'.

/Since: 2.40/
-}
subprocessGetStderrPipe ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Gio.InputStream.InputStream
    {- ^ __Returns:__ the stderr pipe -}
subprocessGetStderrPipe subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_stderr_pipe subprocess'
    checkUnexpectedReturnNULL "subprocessGetStderrPipe" result
    result' <- (newObject Gio.InputStream.InputStream) result
    touchManagedPtr subprocess
    return result'

#if ENABLE_OVERLOADING
data SubprocessGetStderrPipeMethodInfo
instance (signature ~ (m Gio.InputStream.InputStream), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetStderrPipeMethodInfo a signature where
    overloadedMethod _ = subprocessGetStderrPipe

#endif

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

foreign import ccall "g_subprocess_get_stdin_pipe" g_subprocess_get_stdin_pipe ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO (Ptr Gio.OutputStream.OutputStream)

{- |
Gets the 'GI.Gio.Objects.OutputStream.OutputStream' that you can write to in order to give data
to the stdin of /@subprocess@/.

The process must have been created with
'GI.Gio.Flags.SubprocessFlagsStdinPipe'.

/Since: 2.40/
-}
subprocessGetStdinPipe ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Gio.OutputStream.OutputStream
    {- ^ __Returns:__ the stdout pipe -}
subprocessGetStdinPipe subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_stdin_pipe subprocess'
    checkUnexpectedReturnNULL "subprocessGetStdinPipe" result
    result' <- (newObject Gio.OutputStream.OutputStream) result
    touchManagedPtr subprocess
    return result'

#if ENABLE_OVERLOADING
data SubprocessGetStdinPipeMethodInfo
instance (signature ~ (m Gio.OutputStream.OutputStream), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetStdinPipeMethodInfo a signature where
    overloadedMethod _ = subprocessGetStdinPipe

#endif

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

foreign import ccall "g_subprocess_get_stdout_pipe" g_subprocess_get_stdout_pipe ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO (Ptr Gio.InputStream.InputStream)

{- |
Gets the 'GI.Gio.Objects.InputStream.InputStream' from which to read the stdout output of
/@subprocess@/.

The process must have been created with
'GI.Gio.Flags.SubprocessFlagsStdoutPipe'.

/Since: 2.40/
-}
subprocessGetStdoutPipe ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Gio.InputStream.InputStream
    {- ^ __Returns:__ the stdout pipe -}
subprocessGetStdoutPipe subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_stdout_pipe subprocess'
    checkUnexpectedReturnNULL "subprocessGetStdoutPipe" result
    result' <- (newObject Gio.InputStream.InputStream) result
    touchManagedPtr subprocess
    return result'

#if ENABLE_OVERLOADING
data SubprocessGetStdoutPipeMethodInfo
instance (signature ~ (m Gio.InputStream.InputStream), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetStdoutPipeMethodInfo a signature where
    overloadedMethod _ = subprocessGetStdoutPipe

#endif

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

foreign import ccall "g_subprocess_get_successful" g_subprocess_get_successful ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO CInt

{- |
Checks if the process was \"successful\".  A process is considered
successful if it exited cleanly with an exit status of 0, either by
way of the @/exit()/@ system call or return from @/main()/@.

It is an error to call this function before 'GI.Gio.Objects.Subprocess.subprocessWait' has
returned.

/Since: 2.40/
-}
subprocessGetSuccessful ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the process exited cleanly with a exit status of 0 -}
subprocessGetSuccessful subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_successful subprocess'
    let result' = (/= 0) result
    touchManagedPtr subprocess
    return result'

#if ENABLE_OVERLOADING
data SubprocessGetSuccessfulMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetSuccessfulMethodInfo a signature where
    overloadedMethod _ = subprocessGetSuccessful

#endif

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

foreign import ccall "g_subprocess_get_term_sig" g_subprocess_get_term_sig ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    IO Int32

{- |
Get the signal number that caused the subprocess to terminate, given
that it terminated due to a signal.

This is equivalent to the system WTERMSIG macro.

It is an error to call this function before 'GI.Gio.Objects.Subprocess.subprocessWait' and
unless 'GI.Gio.Objects.Subprocess.subprocessGetIfSignaled' returned 'True'.

/Since: 2.40/
-}
subprocessGetTermSig ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> m Int32
    {- ^ __Returns:__ the signal causing termination -}
subprocessGetTermSig subprocess = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result <- g_subprocess_get_term_sig subprocess'
    touchManagedPtr subprocess
    return result

#if ENABLE_OVERLOADING
data SubprocessGetTermSigMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessGetTermSigMethodInfo a signature where
    overloadedMethod _ = subprocessGetTermSig

#endif

-- method Subprocess::send_signal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signal_num", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the signal number to send", 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_send_signal" g_subprocess_send_signal ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Int32 ->                                -- signal_num : TBasicType TInt
    IO ()

{- |
Sends the UNIX signal /@signalNum@/ to the subprocess, if it is still
running.

This API is race-free.  If the subprocess has terminated, it will not
be signalled.

This API is not available on Windows.

/Since: 2.40/
-}
subprocessSendSignal ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> Int32
    {- ^ /@signalNum@/: the signal number to send -}
    -> m ()
subprocessSendSignal subprocess signalNum = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    g_subprocess_send_signal subprocess' signalNum
    touchManagedPtr subprocess
    return ()

#if ENABLE_OVERLOADING
data SubprocessSendSignalMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsSubprocess a) => O.MethodInfo SubprocessSendSignalMethodInfo a signature where
    overloadedMethod _ = subprocessSendSignal

#endif

-- method Subprocess::wait
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_wait" g_subprocess_wait ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Synchronously wait for the subprocess to terminate.

After the process terminates you can query its exit status with
functions such as 'GI.Gio.Objects.Subprocess.subprocessGetIfExited' and
'GI.Gio.Objects.Subprocess.subprocessGetExitStatus'.

This function does not fail in the case of the subprocess having
abnormal termination.  See 'GI.Gio.Objects.Subprocess.subprocessWaitCheck' for that.

Cancelling /@cancellable@/ doesn\'t kill the subprocess.  Call
'GI.Gio.Objects.Subprocess.subprocessForceExit' if it is desirable.

/Since: 2.40/
-}
subprocessWait ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessWait subprocess cancellable = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_subprocess_wait subprocess' maybeCancellable
        touchManagedPtr subprocess
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data SubprocessWaitMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessWaitMethodInfo a signature where
    overloadedMethod _ = subprocessWait

#endif

-- method Subprocess::wait_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the operation is complete", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user_data for @callback", 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_wait_async" g_subprocess_wait_async ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Wait for the subprocess to terminate.

This is the asynchronous version of 'GI.Gio.Objects.Subprocess.subprocessWait'.

/Since: 2.40/
-}
subprocessWaitAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the operation is complete -}
    -> m ()
subprocessWaitAsync subprocess cancellable callback = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_subprocess_wait_async subprocess' maybeCancellable maybeCallback userData
    touchManagedPtr subprocess
    whenJust cancellable touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data SubprocessWaitAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessWaitAsyncMethodInfo a signature where
    overloadedMethod _ = subprocessWaitAsync

#endif

-- method Subprocess::wait_check
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_wait_check" g_subprocess_wait_check ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Combines 'GI.Gio.Objects.Subprocess.subprocessWait' with 'GI.GLib.Functions.spawnCheckExitStatus'.

/Since: 2.40/
-}
subprocessWaitCheck ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessWaitCheck subprocess cancellable = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        _ <- propagateGError $ g_subprocess_wait_check subprocess' maybeCancellable
        touchManagedPtr subprocess
        whenJust cancellable touchManagedPtr
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data SubprocessWaitCheckMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessWaitCheckMethodInfo a signature where
    overloadedMethod _ = subprocessWaitCheck

#endif

-- method Subprocess::wait_check_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GCancellable, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GAsyncReadyCallback to call when the operation is complete", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user_data for @callback", 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_wait_check_async" g_subprocess_wait_check_async ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Combines 'GI.Gio.Objects.Subprocess.subprocessWaitAsync' with 'GI.GLib.Functions.spawnCheckExitStatus'.

This is the asynchronous version of 'GI.Gio.Objects.Subprocess.subprocessWaitCheck'.

/Since: 2.40/
-}
subprocessWaitCheckAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> Maybe (b)
    {- ^ /@cancellable@/: a 'GI.Gio.Objects.Cancellable.Cancellable', or 'Nothing' -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: a 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the operation is complete -}
    -> m ()
subprocessWaitCheckAsync subprocess cancellable callback = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_subprocess_wait_check_async subprocess' maybeCancellable maybeCallback userData
    touchManagedPtr subprocess
    whenJust cancellable touchManagedPtr
    return ()

#if ENABLE_OVERLOADING
data SubprocessWaitCheckAsyncMethodInfo
instance (signature ~ (Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsSubprocess a, Gio.Cancellable.IsCancellable b) => O.MethodInfo SubprocessWaitCheckAsyncMethodInfo a signature where
    overloadedMethod _ = subprocessWaitCheckAsync

#endif

-- method Subprocess::wait_check_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult passed to your #GAsyncReadyCallback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_wait_check_finish" g_subprocess_wait_check_finish ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Collects the result of a previous call to
'GI.Gio.Objects.Subprocess.subprocessWaitCheckAsync'.

/Since: 2.40/
-}
subprocessWaitCheckFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> b
    {- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' passed to your 'GI.Gio.Callbacks.AsyncReadyCallback' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessWaitCheckFinish subprocess result_ = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_subprocess_wait_check_finish subprocess' result_'
        touchManagedPtr subprocess
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data SubprocessWaitCheckFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SubprocessWaitCheckFinishMethodInfo a signature where
    overloadedMethod _ = subprocessWaitCheckFinish

#endif

-- method Subprocess::wait_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "subprocess", argType = TInterface (Name {namespace = "Gio", name = "Subprocess"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GSubprocess", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "result", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GAsyncResult passed to your #GAsyncReadyCallback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "g_subprocess_wait_finish" g_subprocess_wait_finish ::
    Ptr Subprocess ->                       -- subprocess : TInterface (Name {namespace = "Gio", name = "Subprocess"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- result : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Collects the result of a previous call to
'GI.Gio.Objects.Subprocess.subprocessWaitAsync'.

/Since: 2.40/
-}
subprocessWaitFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@subprocess@/: a 'GI.Gio.Objects.Subprocess.Subprocess' -}
    -> b
    {- ^ /@result@/: the 'GI.Gio.Interfaces.AsyncResult.AsyncResult' passed to your 'GI.Gio.Callbacks.AsyncReadyCallback' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
subprocessWaitFinish subprocess result_ = liftIO $ do
    subprocess' <- unsafeManagedPtrCastPtr subprocess
    result_' <- unsafeManagedPtrCastPtr result_
    onException (do
        _ <- propagateGError $ g_subprocess_wait_finish subprocess' result_'
        touchManagedPtr subprocess
        touchManagedPtr result_
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data SubprocessWaitFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsSubprocess a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo SubprocessWaitFinishMethodInfo a signature where
    overloadedMethod _ = subprocessWaitFinish

#endif