Skip to content

Subprocess does not quit after app exit #166

@xinnjie

Description

@xinnjie

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

  1. Create new xcode project for mac SwiftUI app
  2. Add these codes, subprocess dependency and run
import SwiftUI
import Subprocess
struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
        }
        .task {
          let configuration = Configuration(
                      executable: .path("/bin/sleep"),
                      arguments: ["60"]
                  )

          let _ = try! await Subprocess.run(
              configuration,
              output: .discarded,
              error: .discarded
          ) { _ in
          }
        }
        .padding()
    }
}
  1. Open Activity Monitor app and search for sleep process, sleep subprocess shows up.
  2. close mac app quickly
  3. sleep sub process became orphan, and quit after 60 seconds
Image

Expected behavior
A clear and concise description of what you expected to happen.
sleep subprocess quit quickly after parent mac app exit
Environment (please complete the following information):

  • OS [e.g. macOS 15]
    macOS 15
  • Swift version (run swift --version) [e.g. swiftlang-6.2.0.1.23 clang-1700.3.1.3]
    swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
    Target: arm64-apple-macosx15.0
    Additional context
    Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions