Skip to content

Commit 06fa35d

Browse files
committed
update
1 parent 1c0698b commit 06fa35d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ go.sum
77
go.mod
88
tower-app-*
99
.DS_Store
10-
/process/process
10+
/test/process/process

test/process/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func main() {
2525
input, _ := in.ReadString(com.LF)
2626
if input == com.StrLF || input == com.StrCRLF {
2727
color.Green(`[process] restart ==> ` + com.NowStr())
28+
//panic(`[panic]`)
2829
} else {
2930
color.Blue(`[process] waiting ==> ` + com.NowStr())
3031
}

test/process/parent/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package main
22

33
import (
4+
"errors"
5+
"log"
6+
"os"
47
"time"
58

69
"github.com/webx-top/com"
@@ -9,9 +12,18 @@ import (
912
func main() {
1013
ch := com.NewCmdChanReader()
1114
cmd := com.RunCmdWithReaderWriter([]string{`../process`}, ch)
15+
i := 0
1216
for {
1317
ch.Send(com.BreakLine)
1418
time.Sleep(5 * time.Second)
19+
i++
20+
if i >= 3 {
21+
err := cmd.Process.Kill()
22+
if err != nil && !errors.Is(err, os.ErrProcessDone) {
23+
log.Println(err)
24+
}
25+
break
26+
}
1527
}
1628
_ = cmd
1729
}

0 commit comments

Comments
 (0)