@@ -169,6 +169,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
169169 }
170170
171171 private func showConfigurationWindow( ) {
172+ DebugLog . append ( " show configuration window " )
172173 if let window = windowController? . window {
173174 window. makeKeyAndOrderFront ( nil )
174175 NSApp . activate ( ignoringOtherApps: true )
@@ -563,6 +564,7 @@ enum StatusBarIcon {
563564
564565final class ActionRouter {
565566 private let configStore : ConfigStore
567+ private var runningProcesses : [ Process ] = [ ]
566568
567569 init ( configStore: ConfigStore ) {
568570 self . configStore = configStore
@@ -594,15 +596,19 @@ final class ActionRouter {
594596 let output = Pipe ( )
595597 process. standardOutput = output
596598 process. standardError = output
597- process. terminationHandler = { process in
599+ process. terminationHandler = { [ weak self ] process in
598600 let data = output. fileHandleForReading. readDataToEndOfFile ( )
599601 let text = String ( data: data, encoding: . utf8) ?
600602 . trimmingCharacters ( in: . whitespacesAndNewlines) ?? " "
601603 DebugLog . append ( " action finished title= \( action. title) exit= \( process. terminationStatus) output= \( text) " )
604+ DispatchQueue . main. async {
605+ self ? . runningProcesses. removeAll { $0 === process }
606+ }
602607 }
603608
604609 do {
605610 try process. run ( )
611+ runningProcesses. append ( process)
606612 DebugLog . append ( " running action title= \( action. title) command= \( command) " )
607613 } catch {
608614 DebugLog . append ( " action failed title= \( action. title) error= \( error. localizedDescription) " )
0 commit comments