Skip to content

Kill process and all child processes it spawned in Linux or Windows

License

Notifications You must be signed in to change notification settings

kirill-scherba/subprocess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Subprocess

This go package used to Kills process and all child processes it spawned in Linux or Windows.

GoDoc Go Report Card

The main idea behind creating this package is that the Windows code part is very large and it is not practical to copy this code to every project.

Usage example

package main

import "kirill-scherba/subprocess" 

func main() {

    // Create some process, f.e. run exec.Run() function which execute buch 
    // file with subprocesses
    // 
    // var cmd *exec.Cmd
    // var err error
    // cmd, err = exec.Run("executable_name", "parameter")
    // ...
    // Use the KillProcessTree function when you want stop execution started 
    // process and all its child process.
    //

    // Kill the process and all its children
    err = subprocess.KillProcessTree(cmd.Process.Pid)
    if err != nil {
        return
    }

    // ...

}

Licence

BSD