Process

class Process : NSObject
  • Sends an interrupt signal to the process

    Declaration

    Swift

    public func cancel()
  • true if the Process was successfully interrupted, false otherwise

    Declaration

    Swift

    public var isCancelled: Bool { get }
  • Launches the receiver and resolves when it exits, or when the promise is cancelled.

    let proc = Process()
    proc.launchPath = "/bin/ls"
    proc.arguments = ["/bin"]
    let context = proc.launchCC(.promise).compactMap { std in
        String(data: std.out.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8)
    }.then { stdout in
        print(str)
    }.cancelContext
    
    //…
    
    context.cancel()
    

    Declaration

    Swift

    public func launchCC(_: PMKNamespacer) -> CancellablePromise<(out: Pipe, err: Pipe)>