Skip to content

Commit 593e3eb

Browse files
authored
Allow passing process_group flag (#271)
1 parent f99252e commit 593e3eb

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/Database/Postgres/Temp/Internal/Config.hs

+7
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ data ProcessConfig = ProcessConfig
212212
-- ^ A monoid for configuring the standard output 'Handle'.
213213
, stdErr :: Last Handle
214214
-- ^ A monoid for configuring the standard error 'Handle'.
215+
, createGroup :: Any
216+
-- ^ A monoid for combining boolean create process group flag.
217+
-- The first 'True' value wins.
215218
}
216219
deriving stock (Generic, Eq, Show)
217220
deriving Semigroup via GenericSemigroup ProcessConfig
@@ -235,6 +238,9 @@ instance Pretty ProcessConfig where
235238
<> hardline
236239
<> text "stdErr:" <+>
237240
pretty (prettyHandle <$> getLast stdErr)
241+
<> hardline
242+
<> text "createGroup:" <+>
243+
pretty (getAny createGroup)
238244

239245

240246
-- | The 'standardProcessConfig' sets the handles to 'stdin', 'stdout' and
@@ -291,6 +297,7 @@ completeProcessConfig
291297
:: [(String, String)] -> ProcessConfig -> Either [String] CompleteProcessConfig
292298
completeProcessConfig envs ProcessConfig {..} = runErrors $ do
293299
let completeProcessConfigCmdLine = completeCommandLineArgs commandLine
300+
completeProcessConfigCreateGroup = getAny createGroup
294301
completeProcessConfigEnvVars <- eitherToErrors $
295302
completeEnvironmentVariables envs environmentVariables
296303
completeProcessConfigStdIn <-

src/Database/Postgres/Temp/Internal/Core.hs

+12-5
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,18 @@ teeHandle orig f =
138138
-- | 'CompleteProcessConfig' contains the configuration necessary for starting a
139139
-- process. It is essentially a stripped down 'System.Process.CreateProcess'.
140140
data CompleteProcessConfig = CompleteProcessConfig
141-
{ completeProcessConfigEnvVars :: [(String, String)]
141+
{ completeProcessConfigEnvVars :: [(String, String)]
142142
-- ^ Environment variables
143-
, completeProcessConfigCmdLine :: [String]
143+
, completeProcessConfigCmdLine :: [String]
144144
-- ^ Command line arguements
145-
, completeProcessConfigStdIn :: Handle
145+
, completeProcessConfigStdIn :: Handle
146146
-- ^ The 'Handle' for standard input
147-
, completeProcessConfigStdOut :: Handle
147+
, completeProcessConfigStdOut :: Handle
148148
-- ^ The 'Handle' for standard output
149-
, completeProcessConfigStdErr :: Handle
149+
, completeProcessConfigStdErr :: Handle
150150
-- ^ The 'Handle' for standard error
151+
, completeProcessConfigCreateGroup :: Bool
152+
-- ^ Whether or not to create new process group
151153
}
152154

153155
prettyHandle :: Handle -> Doc
@@ -174,6 +176,10 @@ instance Pretty CompleteProcessConfig where
174176
<> hardline
175177
<> text "completeProcessConfigStdErr:"
176178
<+> prettyHandle completeProcessConfigStdErr
179+
<> hardline
180+
<> text "completeProcessConfigCreateGroup:"
181+
<> softline
182+
<> pretty completeProcessConfigCreateGroup
177183

178184
-- | Start a process interactively and return the 'ProcessHandle'
179185
startProcess
@@ -188,6 +194,7 @@ startProcess name CompleteProcessConfig {..} = (\(_, _, _, x) -> x) <$>
188194
, std_out = UseHandle completeProcessConfigStdOut
189195
, std_in = UseHandle completeProcessConfigStdIn
190196
, env = Just completeProcessConfigEnvVars
197+
, create_group = completeProcessConfigCreateGroup
191198
}
192199

193200
-- | Stop a 'ProcessHandle'. An alias for 'waitForProcess'

0 commit comments

Comments
 (0)