feat: add StartProcess, StopProcess, KillProcess for system package

This commit is contained in:
dudaodong committed 2024-09-13 15:09:44 +08:00
1 parent 3e1ac5e0b5
commit e58c9b797b
5 files changed
+316 -15

No files matched your search

+43 -1
View File
@@ -1,6 +1,9 @@
package system
import "fmt"
import (
"fmt"
"time"
)
func ExampleSetOsEnv() {
err := SetOsEnv("foo", "abc")
@@ -75,3 +78,42 @@ func ExampleGetOsBits() {
// Output:
// 64
}
func ExampleStartProcess() {
pid, err := StartProcess("sleep", "2")
if err != nil {
return
}
fmt.Println(pid)
}
func ExampleStopProcess() {
pid, err := StartProcess("sleep", "10")
if err != nil {
return
}
time.Sleep(1 * time.Second)
err = StopProcess(pid)
fmt.Println(err)
// Output:
// <nil>
}
func ExampleKillProcess() {
pid, err := StartProcess("sleep", "3")
if err != nil {
return
}
time.Sleep(1 * time.Second)
err = KillProcess(pid)
fmt.Println(err)
// Output:
// <nil>
}