Skip to content

Set isRunning of Process to false before calling the termination handler #3000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/Foundation/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,9 @@ open class Process: NSObject {
process._terminationReason = .exit
}

// Set the running flag to false
process.isRunning = false

// If a termination handler has been set, invoke it on a background thread

if let terminationHandler = process.terminationHandler {
Expand All @@ -839,9 +842,6 @@ open class Process: NSObject {
thread.start()
}

// Set the running flag to false
process.isRunning = false

// Invalidate the source and wake up the run loop, if it's available

CFRunLoopSourceInvalidate(process.runLoopSource)
Expand Down