Skip to content

Commit

Permalink
Prefer CancellationError to uncaught SIGTERM (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeLyon authored Dec 28, 2021
1 parent 8076673 commit e23c1e6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Sources/Shwift/Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private final class NullDeviceHandler: ChannelInboundHandler {
private final class FatalDeviceHandler: ChannelInboundHandler {
typealias InboundIn = ByteBuffer
func channelRead(context: ChannelHandlerContext, data: NIOAny) {
fatalError()
fatalError(String(buffer: unwrapInboundIn(data)))
}
}

Expand Down
5 changes: 5 additions & 0 deletions Sources/Shwift/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ public struct Process {
break
}

/**
If the task has been cancelled, we want cancellation to supercede the temination status of the executable (often a SIGTERM).
*/
try Task.checkCancellation()

switch Int(info.si_code) {
case Int(CLD_EXITED):
let terminationStatus = info[keyPath: sigchldInfo].si_status
Expand Down
1 change: 1 addition & 0 deletions Support/VSCode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
launch.json
21 changes: 0 additions & 21 deletions Support/VSCode/launch.json

This file was deleted.

0 comments on commit e23c1e6

Please sign in to comment.