Browse Source

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

Terminate local process
Miguel de Icaza 3 năm trước cách đây
mục cha
commit
1b325efdfa

+ 6 - 1
Sources/SwiftTerm/LocalProcess.swift

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