Skip to content

Commit 3917784

Browse files
committed
Do not set the fg pgid to child process by default
1 parent 24b78ce commit 3917784

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Sources/swift-sh/swift-sh⊳run.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ struct Run : AsyncParsableCommand {
1919
@OptionGroup
2020
var runOptions: BuildAndRunOptions
2121

22+
@Flag(name: .customLong("set-fg-pgid-for-stdin"), inversion: .prefixedNo, help: """
23+
Set this to set the foreground group ID associated with the controlling terminal to “your” stdin.
24+
What this means is you’ll receive text typed in the Terminal when reading stdin if the flag is set, otherwise you won’t.
25+
This is disabled by default because this will _also_ send you the signals, and Swift ignores the Ctrl-C signal for some reasons, which is not convenient.
26+
""")
27+
var setFgPgID = false
28+
2229
@Argument(parsing: .captureForPassthrough)
2330
var scriptArguments: [String] = []
2431

@@ -30,7 +37,7 @@ struct Run : AsyncParsableCommand {
3037
logger.trace("Running script.", metadata: ["invocation": .array((["swift"] + allArgs).map{ "\($0)" })])
3138
let (exitCode, terminationReason) = try await ProcessInvocation(
3239
swiftPath, args: allArgs, usePATH: true,
33-
stdinRedirect: stdinData.flatMap{ .send($0) } ?? .none(), stdoutRedirect: .none, stderrRedirect: .none,
40+
stdinRedirect: stdinData.flatMap{ .send($0) } ?? .none(setFgPgID: setFgPgID), stdoutRedirect: .none, stderrRedirect: .none,
3441
signalHandling: { .mapForChild(for: $0, with: [.interrupt: .terminated]/* Swift eats the interrupts for some reasons… */) },
3542
expectedTerminations: .some(nil)
3643
).invokeAndStreamOutput(checkValidTerminations: false/* Doesn’t matter, all terminations are valid. */, outputHandler: { _, _, _ in })

0 commit comments

Comments
 (0)