You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package staros
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_Process(t *testing.T) {
|
|
|
|
fmt.Println(FindProcessByPid(16652))
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_StarCmd(t *testing.T) {
|
|
|
|
ctx, _ := context.WithTimeout(context.Background(), time.Second*5)
|
|
|
|
cmd, _ := CommandContext(ctx, "cmd.exe", "/c", "ping -t 127.0.0.1")
|
|
|
|
cmd.Start()
|
|
|
|
for cmd.IsRunning() {
|
|
|
|
fmt.Print(cmd.NowLineOutput())
|
|
|
|
time.Sleep(time.Millisecond * 50)
|
|
|
|
}
|
|
|
|
fmt.Println(cmd.NowAllOutput())
|
|
|
|
fmt.Print("all is ")
|
|
|
|
fmt.Println(cmd.AllOutPut())
|
|
|
|
fmt.Println(cmd.ExitCode())
|
|
|
|
|
|
|
|
}
|