浏览代码

Merge pull request #204 from krzyzanowskim/marcin/terminate-localprocess

Terminate local process
Miguel de Icaza 3 年之前
父节点
当前提交
1b325efdfa
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      Sources/SwiftTerm/LocalProcess.swift

+ 6 - 1
Sources/SwiftTerm/LocalProcess.swift

@@ -53,7 +53,7 @@ public class LocalProcess {
     public private(set) var childfd: Int32 = -1
     
     /* The PID of our subprocess */
-    var shellPid: pid_t = 0
+    public private(set) var shellPid: pid_t = 0
     var debugIO = false
     
     /* number of sent requests */
@@ -208,6 +208,11 @@ public class LocalProcess {
             DispatchIO.read(fromFileDescriptor: childfd, maxLength: readBuffer.count, runningHandlerOn: dispatchQueue, handler: childProcessRead)
         }
     }
+
+    public func terminate()
+    {
+        kill(shellPid, SIGTERM)
+    }
     
     var loggingDir: String? = nil