{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'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:
-- t'GI.Gio.Objects.InputStream.InputStream', t'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 t'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.
-- 
-- t'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
-- t'GI.Gio.Objects.Subprocess.Subprocess' API (unless 'GI.Gio.Flags.SubprocessFlagsInheritFds' was
-- specified).
-- 
-- t'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, t'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.
-- 
-- t'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
-- t'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 t'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/

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

module GI.Gio.Objects.Subprocess
    ( 

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


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveSubprocessMethod                 ,
#endif


-- ** communicate #method:communicate#

#if defined(ENABLE_OVERLOADING)
    SubprocessCommunicateMethodInfo         ,
#endif
    subprocessCommunicate                   ,


-- ** communicateAsync #method:communicateAsync#

#if defined(ENABLE_OVERLOADING)
    SubprocessCommunicateAsyncMethodInfo    ,
#endif
    subprocessCommunicateAsync              ,


-- ** communicateFinish #method:communicateFinish#

#if defined(ENABLE_OVERLOADING)
    SubprocessCommunicateFinishMethodInfo   ,
#endif
    subprocessCommunicateFinish             ,


-- ** communicateUtf8 #method:communicateUtf8#

#if defined(ENABLE_OVERLOADING)
    SubprocessCommunicateUtf8MethodInfo     ,
#endif
    subprocessCommunicateUtf8               ,


-- ** communicateUtf8Async #method:communicateUtf8Async#

#if defined(ENABLE_OVERLOADING)
    SubprocessCommunicateUtf8AsyncMethodInfo,
#endif
    subprocessCommunicateUtf8Async          ,


-- ** communicateUtf8Finish #method:communicateUtf8Finish#

#if defined(ENABLE_OVERLOADING)
    SubprocessCommunicateUtf8FinishMethodInfo,
#endif
    subprocessCommunicateUtf8Finish         ,


-- ** forceExit #method:forceExit#

#if defined(ENABLE_OVERLOADING)
    SubprocessForceExitMethodInfo           ,
#endif
    subprocessForceExit                     ,


-- ** getExitStatus #method:getExitStatus#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetExitStatusMethodInfo       ,
#endif
    subprocessGetExitStatus                 ,


-- ** getIdentifier #method:getIdentifier#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetIdentifierMethodInfo       ,
#endif
    subprocessGetIdentifier                 ,


-- ** getIfExited #method:getIfExited#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetIfExitedMethodInfo         ,
#endif
    subprocessGetIfExited                   ,


-- ** getIfSignaled #method:getIfSignaled#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetIfSignaledMethodInfo       ,
#endif
    subprocessGetIfSignaled                 ,


-- ** getStatus #method:getStatus#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetStatusMethodInfo           ,
#endif
    subprocessGetStatus                     ,


-- ** getStderrPipe #method:getStderrPipe#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetStderrPipeMethodInfo       ,
#endif
    subprocessGetStderrPipe                 ,


-- ** getStdinPipe #method:getStdinPipe#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetStdinPipeMethodInfo        ,
#endif
    subprocessGetStdinPipe                  ,


-- ** getStdoutPipe #method:getStdoutPipe#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetStdoutPipeMethodInfo       ,
#endif
    subprocessGetStdoutPipe                 ,


-- ** getSuccessful #method:getSuccessful#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetSuccessfulMethodInfo       ,
#endif
    subprocessGetSuccessful                 ,


-- ** getTermSig #method:getTermSig#

#if defined(ENABLE_OVERLOADING)
    SubprocessGetTermSigMethodInfo          ,
#endif
    subprocessGetTermSig                    ,


-- ** new #method:new#

    subprocessNew                           ,


-- ** sendSignal #method:sendSignal#

#if defined(ENABLE_OVERLOADING)
    SubprocessSendSignalMethodInfo          ,
#endif
    subprocessSendSignal                    ,


-- ** wait #method:wait#

#if defined(ENABLE_OVERLOADING)
    SubprocessWaitMethodInfo                ,
#endif
    subprocessWait                          ,


-- ** waitAsync #method:waitAsync#

#if defined(ENABLE_OVERLOADING)
    SubprocessWaitAsyncMethodInfo           ,
#endif
    subprocessWaitAsync                     ,


-- ** waitCheck #method:waitCheck#

#if defined(ENABLE_OVERLOADING)
    SubprocessWaitCheckMethodInfo           ,
#endif
    subprocessWaitCheck                     ,


-- ** waitCheckAsync #method:waitCheckAsync#

#if defined(ENABLE_OVERLOADING)
    SubprocessWaitCheckAsyncMethodInfo      ,
#endif
    subprocessWaitCheckAsync                ,


-- ** waitCheckFinish #method:waitCheckFinish#

#if defined(ENABLE_OVERLOADING)
    SubprocessWaitCheckFinishMethodInfo     ,
#endif
    subprocessWaitCheckFinish               ,


-- ** waitFinish #method:waitFinish#

#if defined(ENABLE_OVERLOADING)
    SubprocessWaitFinishMethodInfo          ,
#endif
    subprocessWaitFinish                    ,




 -- * Properties
-- ** argv #attr:argv#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SubprocessArgvPropertyInfo              ,
#endif
    constructSubprocessArgv                 ,
#if defined(ENABLE_OVERLOADING)
    subprocessArgv                          ,
#endif


-- ** flags #attr:flags#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    SubprocessFlagsPropertyInfo             ,
#endif
    constructSubprocessFlags                ,
#if defined(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.GI.Base.Signals as B.Signals
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)
    deriving (Subprocess -> Subprocess -> Bool
(Subprocess -> Subprocess -> Bool)
-> (Subprocess -> Subprocess -> Bool) -> Eq Subprocess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subprocess -> Subprocess -> Bool
$c/= :: Subprocess -> Subprocess -> Bool
== :: Subprocess -> Subprocess -> Bool
$c== :: Subprocess -> Subprocess -> Bool
Eq)
foreign import ccall "g_subprocess_get_type"
    c_g_subprocess_get_type :: IO GType

instance GObject Subprocess where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_subprocess_get_type
    

-- | Convert 'Subprocess' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Subprocess where
    toGValue :: Subprocess -> IO GValue
toGValue o :: Subprocess
o = do
        GType
gtype <- IO GType
c_g_subprocess_get_type
        Subprocess -> (Ptr Subprocess -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Subprocess
o (GType
-> (GValue -> Ptr Subprocess -> IO ())
-> Ptr Subprocess
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Subprocess -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO Subprocess
fromGValue gv :: GValue
gv = do
        Ptr Subprocess
ptr <- GValue -> IO (Ptr Subprocess)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr Subprocess)
        (ManagedPtr Subprocess -> Subprocess)
-> Ptr Subprocess -> IO Subprocess
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr Subprocess -> Subprocess
Subprocess Ptr Subprocess
ptr
        
    

-- | 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 :: o -> m Subprocess
toSubprocess = IO Subprocess -> m Subprocess
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Subprocess -> m Subprocess)
-> (o -> IO Subprocess) -> o -> m Subprocess
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr Subprocess -> Subprocess) -> o -> IO Subprocess
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr Subprocess -> Subprocess
Subprocess

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

#if defined(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 @info
#else
    fromLabel _ = O.overloadedMethod @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 :: [Text] -> IO (GValueConstruct o)
constructSubprocessArgv val :: [Text]
val = String -> Maybe [Text] -> IO (GValueConstruct o)
forall o. String -> Maybe [Text] -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyStringArray "argv" ([Text] -> Maybe [Text]
forall a. a -> Maybe a
Just [Text]
val)

#if defined(ENABLE_OVERLOADING)
data SubprocessArgvPropertyInfo
instance AttrInfo SubprocessArgvPropertyInfo where
    type AttrAllowedOps SubprocessArgvPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrBaseTypeConstraint SubprocessArgvPropertyInfo = IsSubprocess
    type AttrSetTypeConstraint SubprocessArgvPropertyInfo = (~) [T.Text]
    type AttrTransferTypeConstraint SubprocessArgvPropertyInfo = (~) [T.Text]
    type AttrTransferType SubprocessArgvPropertyInfo = [T.Text]
    type AttrGetType SubprocessArgvPropertyInfo = ()
    type AttrLabel SubprocessArgvPropertyInfo = "argv"
    type AttrOrigin SubprocessArgvPropertyInfo = Subprocess
    attrGet = undefined
    attrSet = undefined
    attrTransfer _ v = do
        return v
    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 :: [SubprocessFlags] -> IO (GValueConstruct o)
constructSubprocessFlags val :: [SubprocessFlags]
val = String -> [SubprocessFlags] -> IO (GValueConstruct o)
forall a o.
(IsGFlag a, BoxedFlags a) =>
String -> [a] -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyFlags "flags" [SubprocessFlags]
val

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

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

#if defined(ENABLE_OVERLOADING)
subprocessArgv :: AttrLabelProxy "argv"
subprocessArgv = AttrLabelProxy

subprocessFlags :: AttrLabelProxy "flags"
subprocessFlags = AttrLabelProxy

#endif

#if defined(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 'P.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 t'GI.Gio.Objects.Subprocess.Subprocess', or 'P.Nothing' on error (and /@error@/
    --   will be set) /(Can throw 'Data.GI.Base.GError.GError')/
subprocessNew :: [String] -> [SubprocessFlags] -> m Subprocess
subprocessNew argv :: [String]
argv flags :: [SubprocessFlags]
flags = IO Subprocess -> m Subprocess
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Subprocess -> m Subprocess) -> IO Subprocess -> m Subprocess
forall a b. (a -> b) -> a -> b
$ do
    Ptr CString
argv' <- [String] -> IO (Ptr CString)
packZeroTerminatedFileNameArray [String]
argv
    let flags' :: CUInt
flags' = [SubprocessFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [SubprocessFlags]
flags
    IO Subprocess -> IO () -> IO Subprocess
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Subprocess
result <- (Ptr (Ptr GError) -> IO (Ptr Subprocess)) -> IO (Ptr Subprocess)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Subprocess)) -> IO (Ptr Subprocess))
-> (Ptr (Ptr GError) -> IO (Ptr Subprocess)) -> IO (Ptr Subprocess)
forall a b. (a -> b) -> a -> b
$ Ptr CString -> CUInt -> Ptr (Ptr GError) -> IO (Ptr Subprocess)
g_subprocess_newv Ptr CString
argv' CUInt
flags'
        Text -> Ptr Subprocess -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "subprocessNew" Ptr Subprocess
result
        Subprocess
result' <- ((ManagedPtr Subprocess -> Subprocess)
-> Ptr Subprocess -> IO Subprocess
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Subprocess -> Subprocess
Subprocess) Ptr Subprocess
result
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Subprocess -> IO Subprocess
forall (m :: * -> *) a. Monad m => a -> m a
return Subprocess
result'
     ) (do
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
argv'
     )

#if defined(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 'P.Nothing'.  Similar provisions apply to
-- /@stderrBuf@/ and 'GI.Gio.Flags.SubprocessFlagsStderrPipe'.
-- 
-- As usual, any output variable may be given as 'P.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 'P.Nothing'.
-- 
-- In case of any error (including cancellation), 'P.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 'P.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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> Maybe (GLib.Bytes.Bytes)
    -- ^ /@stdinBuf@/: data to send to the stdin of the subprocess, or 'P.Nothing'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable'
    -> m ((Maybe GLib.Bytes.Bytes, Maybe GLib.Bytes.Bytes))
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
subprocessCommunicate :: a -> Maybe Bytes -> Maybe b -> m (Maybe Bytes, Maybe Bytes)
subprocessCommunicate subprocess :: a
subprocess stdinBuf :: Maybe Bytes
stdinBuf cancellable :: Maybe b
cancellable = IO (Maybe Bytes, Maybe Bytes) -> m (Maybe Bytes, Maybe Bytes)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Bytes, Maybe Bytes) -> m (Maybe Bytes, Maybe Bytes))
-> IO (Maybe Bytes, Maybe Bytes) -> m (Maybe Bytes, Maybe Bytes)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Bytes
maybeStdinBuf <- case Maybe Bytes
stdinBuf of
        Nothing -> Ptr Bytes -> IO (Ptr Bytes)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Bytes
forall a. Ptr a
nullPtr
        Just jStdinBuf :: Bytes
jStdinBuf -> do
            Ptr Bytes
jStdinBuf' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
jStdinBuf
            Ptr Bytes -> IO (Ptr Bytes)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Bytes
jStdinBuf'
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    Ptr (Ptr Bytes)
stdoutBuf <- IO (Ptr (Ptr Bytes))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    Ptr (Ptr Bytes)
stderrBuf <- IO (Ptr (Ptr Bytes))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    IO (Maybe Bytes, Maybe Bytes)
-> IO () -> IO (Maybe Bytes, Maybe Bytes)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess
-> Ptr Bytes
-> Ptr Cancellable
-> Ptr (Ptr Bytes)
-> Ptr (Ptr Bytes)
-> Ptr (Ptr GError)
-> IO CInt
g_subprocess_communicate Ptr Subprocess
subprocess' Ptr Bytes
maybeStdinBuf Ptr Cancellable
maybeCancellable Ptr (Ptr Bytes)
stdoutBuf Ptr (Ptr Bytes)
stderrBuf
        Ptr Bytes
stdoutBuf' <- Ptr (Ptr Bytes) -> IO (Ptr Bytes)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Bytes)
stdoutBuf
        Maybe Bytes
maybeStdoutBuf' <- Ptr Bytes -> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Bytes
stdoutBuf' ((Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes))
-> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. (a -> b) -> a -> b
$ \stdoutBuf'' :: Ptr Bytes
stdoutBuf'' -> do
            Bytes
stdoutBuf''' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
stdoutBuf''
            Bytes -> IO Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
stdoutBuf'''
        Ptr Bytes
stderrBuf' <- Ptr (Ptr Bytes) -> IO (Ptr Bytes)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Bytes)
stderrBuf
        Maybe Bytes
maybeStderrBuf' <- Ptr Bytes -> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Bytes
stderrBuf' ((Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes))
-> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. (a -> b) -> a -> b
$ \stderrBuf'' :: Ptr Bytes
stderrBuf'' -> do
            Bytes
stderrBuf''' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
stderrBuf''
            Bytes -> IO Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
stderrBuf'''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        Maybe Bytes -> (Bytes -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Bytes
stdinBuf Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stdoutBuf
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stderrBuf
        (Maybe Bytes, Maybe Bytes) -> IO (Maybe Bytes, Maybe Bytes)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Bytes
maybeStdoutBuf', Maybe Bytes
maybeStderrBuf')
     ) (do
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stdoutBuf
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stderrBuf
     )

#if defined(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 'P.Nothing'
    -> Maybe (b)
    -- ^ /@cancellable@/: Cancellable
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: Callback
    -> m ()
subprocessCommunicateAsync :: a -> Maybe Bytes -> Maybe b -> Maybe AsyncReadyCallback -> m ()
subprocessCommunicateAsync subprocess :: a
subprocess stdinBuf :: Maybe Bytes
stdinBuf cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Bytes
maybeStdinBuf <- case Maybe Bytes
stdinBuf of
        Nothing -> Ptr Bytes -> IO (Ptr Bytes)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Bytes
forall a. Ptr a
nullPtr
        Just jStdinBuf :: Bytes
jStdinBuf -> do
            Ptr Bytes
jStdinBuf' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
jStdinBuf
            Ptr Bytes -> IO (Ptr Bytes)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Bytes
jStdinBuf'
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Subprocess
-> Ptr Bytes
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_subprocess_communicate_async Ptr Subprocess
subprocess' Ptr Bytes
maybeStdinBuf Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Maybe Bytes -> (Bytes -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Bytes
stdinBuf Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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 :: a -> b -> m (Maybe Bytes, Maybe Bytes)
subprocessCommunicateFinish subprocess :: a
subprocess result_ :: b
result_ = IO (Maybe Bytes, Maybe Bytes) -> m (Maybe Bytes, Maybe Bytes)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Bytes, Maybe Bytes) -> m (Maybe Bytes, Maybe Bytes))
-> IO (Maybe Bytes, Maybe Bytes) -> m (Maybe Bytes, Maybe Bytes)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    Ptr (Ptr Bytes)
stdoutBuf <- IO (Ptr (Ptr Bytes))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    Ptr (Ptr Bytes)
stderrBuf <- IO (Ptr (Ptr Bytes))
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr (Ptr GLib.Bytes.Bytes))
    IO (Maybe Bytes, Maybe Bytes)
-> IO () -> IO (Maybe Bytes, Maybe Bytes)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess
-> Ptr AsyncResult
-> Ptr (Ptr Bytes)
-> Ptr (Ptr Bytes)
-> Ptr (Ptr GError)
-> IO CInt
g_subprocess_communicate_finish Ptr Subprocess
subprocess' Ptr AsyncResult
result_' Ptr (Ptr Bytes)
stdoutBuf Ptr (Ptr Bytes)
stderrBuf
        Ptr Bytes
stdoutBuf' <- Ptr (Ptr Bytes) -> IO (Ptr Bytes)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Bytes)
stdoutBuf
        Maybe Bytes
maybeStdoutBuf' <- Ptr Bytes -> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Bytes
stdoutBuf' ((Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes))
-> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. (a -> b) -> a -> b
$ \stdoutBuf'' :: Ptr Bytes
stdoutBuf'' -> do
            Bytes
stdoutBuf''' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
stdoutBuf''
            Bytes -> IO Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
stdoutBuf'''
        Ptr Bytes
stderrBuf' <- Ptr (Ptr Bytes) -> IO (Ptr Bytes)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Bytes)
stderrBuf
        Maybe Bytes
maybeStderrBuf' <- Ptr Bytes -> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Bytes
stderrBuf' ((Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes))
-> (Ptr Bytes -> IO Bytes) -> IO (Maybe Bytes)
forall a b. (a -> b) -> a -> b
$ \stderrBuf'' :: Ptr Bytes
stderrBuf'' -> do
            Bytes
stderrBuf''' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
stderrBuf''
            Bytes -> IO Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
stderrBuf'''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stdoutBuf
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stderrBuf
        (Maybe Bytes, Maybe Bytes) -> IO (Maybe Bytes, Maybe Bytes)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Bytes
maybeStdoutBuf', Maybe Bytes
maybeStderrBuf')
     ) (do
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stdoutBuf
        Ptr (Ptr Bytes) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Bytes)
stderrBuf
     )

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> Maybe (T.Text)
    -- ^ /@stdinBuf@/: data to send to the stdin of the subprocess, or 'P.Nothing'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable'
    -> m ((Maybe T.Text, Maybe T.Text))
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
subprocessCommunicateUtf8 :: a -> Maybe Text -> Maybe b -> m (Maybe Text, Maybe Text)
subprocessCommunicateUtf8 subprocess :: a
subprocess stdinBuf :: Maybe Text
stdinBuf cancellable :: Maybe b
cancellable = IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text))
-> IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    CString
maybeStdinBuf <- case Maybe Text
stdinBuf of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jStdinBuf :: Text
jStdinBuf -> do
            CString
jStdinBuf' <- Text -> IO CString
textToCString Text
jStdinBuf
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStdinBuf'
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    Ptr CString
stdoutBuf <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    Ptr CString
stderrBuf <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    IO (Maybe Text, Maybe Text) -> IO () -> IO (Maybe Text, Maybe Text)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess
-> CString
-> Ptr Cancellable
-> Ptr CString
-> Ptr CString
-> Ptr (Ptr GError)
-> IO CInt
g_subprocess_communicate_utf8 Ptr Subprocess
subprocess' CString
maybeStdinBuf Ptr Cancellable
maybeCancellable Ptr CString
stdoutBuf Ptr CString
stderrBuf
        CString
stdoutBuf' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
stdoutBuf
        Maybe Text
maybeStdoutBuf' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
stdoutBuf' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \stdoutBuf'' :: CString
stdoutBuf'' -> do
            Text
stdoutBuf''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
stdoutBuf''
            Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
stdoutBuf'''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
stdoutBuf'
        CString
stderrBuf' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
stderrBuf
        Maybe Text
maybeStderrBuf' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
stderrBuf' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \stderrBuf'' :: CString
stderrBuf'' -> do
            Text
stderrBuf''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
stderrBuf''
            Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
stderrBuf'''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
stderrBuf'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStdinBuf
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stdoutBuf
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stderrBuf
        (Maybe Text, Maybe Text) -> IO (Maybe Text, Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Text
maybeStdoutBuf', Maybe Text
maybeStderrBuf')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStdinBuf
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stdoutBuf
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stderrBuf
     )

#if defined(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 'P.Nothing'
    -> Maybe (b)
    -- ^ /@cancellable@/: Cancellable
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: Callback
    -> m ()
subprocessCommunicateUtf8Async :: a -> Maybe Text -> Maybe b -> Maybe AsyncReadyCallback -> m ()
subprocessCommunicateUtf8Async subprocess :: a
subprocess stdinBuf :: Maybe Text
stdinBuf cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    CString
maybeStdinBuf <- case Maybe Text
stdinBuf of
        Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just jStdinBuf :: Text
jStdinBuf -> do
            CString
jStdinBuf' <- Text -> IO CString
textToCString Text
jStdinBuf
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStdinBuf'
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Subprocess
-> CString
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_subprocess_communicate_utf8_async Ptr Subprocess
subprocess' CString
maybeStdinBuf Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStdinBuf
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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 :: a -> b -> m (Maybe Text, Maybe Text)
subprocessCommunicateUtf8Finish subprocess :: a
subprocess result_ :: b
result_ = IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text))
-> IO (Maybe Text, Maybe Text) -> m (Maybe Text, Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    Ptr CString
stdoutBuf <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    Ptr CString
stderrBuf <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CString)
    IO (Maybe Text, Maybe Text) -> IO () -> IO (Maybe Text, Maybe Text)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess
-> Ptr AsyncResult
-> Ptr CString
-> Ptr CString
-> Ptr (Ptr GError)
-> IO CInt
g_subprocess_communicate_utf8_finish Ptr Subprocess
subprocess' Ptr AsyncResult
result_' Ptr CString
stdoutBuf Ptr CString
stderrBuf
        CString
stdoutBuf' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
stdoutBuf
        Maybe Text
maybeStdoutBuf' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
stdoutBuf' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \stdoutBuf'' :: CString
stdoutBuf'' -> do
            Text
stdoutBuf''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
stdoutBuf''
            Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
stdoutBuf'''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
stdoutBuf'
        CString
stderrBuf' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
stderrBuf
        Maybe Text
maybeStderrBuf' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
stderrBuf' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \stderrBuf'' :: CString
stderrBuf'' -> do
            Text
stderrBuf''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
stderrBuf''
            Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
stderrBuf'''
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
stderrBuf'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stdoutBuf
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stderrBuf
        (Maybe Text, Maybe Text) -> IO (Maybe Text, Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Text
maybeStdoutBuf', Maybe Text
maybeStderrBuf')
     ) (do
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stdoutBuf
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
stderrBuf
     )

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m ()
subprocessForceExit :: a -> m ()
subprocessForceExit subprocess :: a
subprocess = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Subprocess -> IO ()
g_subprocess_force_exit Ptr Subprocess
subprocess'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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 'P.True'.
-- 
-- /Since: 2.40/
subprocessGetExitStatus ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    -- ^ /@subprocess@/: a t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Int32
    -- ^ __Returns:__ the exit status
subprocessGetExitStatus :: a -> m Int32
subprocessGetExitStatus subprocess :: a
subprocess = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Int32
result <- Ptr Subprocess -> IO Int32
g_subprocess_get_exit_status Ptr Subprocess
subprocess'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m T.Text
subprocessGetIdentifier :: a -> m Text
subprocessGetIdentifier subprocess :: a
subprocess = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    CString
result <- Ptr Subprocess -> IO CString
g_subprocess_get_identifier Ptr Subprocess
subprocess'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "subprocessGetIdentifier" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the case of a normal exit
subprocessGetIfExited :: a -> m Bool
subprocessGetIfExited subprocess :: a
subprocess = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    CInt
result <- Ptr Subprocess -> IO CInt
g_subprocess_get_if_exited Ptr Subprocess
subprocess'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the case of termination due to a signal
subprocessGetIfSignaled :: a -> m Bool
subprocessGetIfSignaled subprocess :: a
subprocess = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    CInt
result <- Ptr Subprocess -> IO CInt
g_subprocess_get_if_signaled Ptr Subprocess
subprocess'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Int32
    -- ^ __Returns:__ the (meaningless) @/waitpid()/@ exit status from the kernel
subprocessGetStatus :: a -> m Int32
subprocessGetStatus subprocess :: a
subprocess = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Int32
result <- Ptr Subprocess -> IO Int32
g_subprocess_get_status Ptr Subprocess
subprocess'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(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 t'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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Gio.InputStream.InputStream
    -- ^ __Returns:__ the stderr pipe
subprocessGetStderrPipe :: a -> m InputStream
subprocessGetStderrPipe subprocess :: a
subprocess = IO InputStream -> m InputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO InputStream -> m InputStream)
-> IO InputStream -> m InputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr InputStream
result <- Ptr Subprocess -> IO (Ptr InputStream)
g_subprocess_get_stderr_pipe Ptr Subprocess
subprocess'
    Text -> Ptr InputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "subprocessGetStderrPipe" Ptr InputStream
result
    InputStream
result' <- ((ManagedPtr InputStream -> InputStream)
-> Ptr InputStream -> IO InputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr InputStream -> InputStream
Gio.InputStream.InputStream) Ptr InputStream
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    InputStream -> IO InputStream
forall (m :: * -> *) a. Monad m => a -> m a
return InputStream
result'

#if defined(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 t'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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Gio.OutputStream.OutputStream
    -- ^ __Returns:__ the stdout pipe
subprocessGetStdinPipe :: a -> m OutputStream
subprocessGetStdinPipe subprocess :: a
subprocess = IO OutputStream -> m OutputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OutputStream -> m OutputStream)
-> IO OutputStream -> m OutputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr OutputStream
result <- Ptr Subprocess -> IO (Ptr OutputStream)
g_subprocess_get_stdin_pipe Ptr Subprocess
subprocess'
    Text -> Ptr OutputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "subprocessGetStdinPipe" Ptr OutputStream
result
    OutputStream
result' <- ((ManagedPtr OutputStream -> OutputStream)
-> Ptr OutputStream -> IO OutputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr OutputStream -> OutputStream
Gio.OutputStream.OutputStream) Ptr OutputStream
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    OutputStream -> IO OutputStream
forall (m :: * -> *) a. Monad m => a -> m a
return OutputStream
result'

#if defined(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 t'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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Gio.InputStream.InputStream
    -- ^ __Returns:__ the stdout pipe
subprocessGetStdoutPipe :: a -> m InputStream
subprocessGetStdoutPipe subprocess :: a
subprocess = IO InputStream -> m InputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO InputStream -> m InputStream)
-> IO InputStream -> m InputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr InputStream
result <- Ptr Subprocess -> IO (Ptr InputStream)
g_subprocess_get_stdout_pipe Ptr Subprocess
subprocess'
    Text -> Ptr InputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "subprocessGetStdoutPipe" Ptr InputStream
result
    InputStream
result' <- ((ManagedPtr InputStream -> InputStream)
-> Ptr InputStream -> IO InputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr InputStream -> InputStream
Gio.InputStream.InputStream) Ptr InputStream
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    InputStream -> IO InputStream
forall (m :: * -> *) a. Monad m => a -> m a
return InputStream
result'

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the process exited cleanly with a exit status of 0
subprocessGetSuccessful :: a -> m Bool
subprocessGetSuccessful subprocess :: a
subprocess = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    CInt
result <- Ptr Subprocess -> IO CInt
g_subprocess_get_successful Ptr Subprocess
subprocess'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(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 'P.True'.
-- 
-- /Since: 2.40/
subprocessGetTermSig ::
    (B.CallStack.HasCallStack, MonadIO m, IsSubprocess a) =>
    a
    -- ^ /@subprocess@/: a t'GI.Gio.Objects.Subprocess.Subprocess'
    -> m Int32
    -- ^ __Returns:__ the signal causing termination
subprocessGetTermSig :: a -> m Int32
subprocessGetTermSig subprocess :: a
subprocess = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Int32
result <- Ptr Subprocess -> IO Int32
g_subprocess_get_term_sig Ptr Subprocess
subprocess'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> Int32
    -- ^ /@signalNum@/: the signal number to send
    -> m ()
subprocessSendSignal :: a -> Int32 -> m ()
subprocessSendSignal subprocess :: a
subprocess signalNum :: Int32
signalNum = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Subprocess -> Int32 -> IO ()
g_subprocess_send_signal Ptr Subprocess
subprocess' Int32
signalNum
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable'
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
subprocessWait :: a -> Maybe b -> m ()
subprocessWait subprocess :: a
subprocess cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_subprocess_wait Ptr Subprocess
subprocess' Ptr Cancellable
maybeCancellable
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: a t'GI.Gio.Callbacks.AsyncReadyCallback' to call when the operation is complete
    -> m ()
subprocessWaitAsync :: a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
subprocessWaitAsync subprocess :: a
subprocess cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Subprocess
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_subprocess_wait_async Ptr Subprocess
subprocess' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable'
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
subprocessWaitCheck :: a -> Maybe b -> m ()
subprocessWaitCheck subprocess :: a
subprocess cancellable :: Maybe b
cancellable = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_subprocess_wait_check Ptr Subprocess
subprocess' Ptr Cancellable
maybeCancellable
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> Maybe (b)
    -- ^ /@cancellable@/: a t'GI.Gio.Objects.Cancellable.Cancellable', or 'P.Nothing'
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    -- ^ /@callback@/: a t'GI.Gio.Callbacks.AsyncReadyCallback' to call when the operation is complete
    -> m ()
subprocessWaitCheckAsync :: a -> Maybe b -> Maybe AsyncReadyCallback -> m ()
subprocessWaitCheckAsync subprocess :: a
subprocess cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
        Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
        Just jCancellable :: b
jCancellable -> do
            Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
            Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
    FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
        Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
        Just jCallback :: AsyncReadyCallback
jCallback -> do
            Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
            FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
            Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
            FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    Ptr Subprocess
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_subprocess_wait_check_async Ptr Subprocess
subprocess' Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
    Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> b
    -- ^ /@result@/: the t'GI.Gio.Interfaces.AsyncResult.AsyncResult' passed to your t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
subprocessWaitCheckFinish :: a -> b -> m ()
subprocessWaitCheckFinish subprocess :: a
subprocess result_ :: b
result_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_subprocess_wait_check_finish Ptr Subprocess
subprocess' Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(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 t'GI.Gio.Objects.Subprocess.Subprocess'
    -> b
    -- ^ /@result@/: the t'GI.Gio.Interfaces.AsyncResult.AsyncResult' passed to your t'GI.Gio.Callbacks.AsyncReadyCallback'
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
subprocessWaitFinish :: a -> b -> m ()
subprocessWaitFinish subprocess :: a
subprocess result_ :: b
result_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Subprocess
subprocess' <- a -> IO (Ptr Subprocess)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
subprocess
    Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Subprocess -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_subprocess_wait_finish Ptr Subprocess
subprocess' Ptr AsyncResult
result_'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
subprocess
        b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(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