File tree Expand file tree Collapse file tree 5 files changed +65
-3
lines changed Expand file tree Collapse file tree 5 files changed +65
-3
lines changed Original file line number Diff line number Diff line change @@ -106,11 +106,11 @@ type StdPipe struct {
106
106
}
107
107
108
108
func StdDup () (* StdPipe , error ) {
109
- in , err := syscall . Dup (syscall .Stdin )
109
+ in , err := sys_dup (syscall .Stdin )
110
110
if err != nil {
111
111
return nil , err
112
112
}
113
- out , err := syscall . Dup (syscall .Stdout )
113
+ out , err := sys_dup (syscall .Stdout )
114
114
if err != nil {
115
115
return nil , err
116
116
}
Original file line number Diff line number Diff line change
1
+ //go:build !windows
2
+
3
+ package cmdio
4
+
5
+ import (
6
+ "syscall"
7
+ )
8
+
9
+ type Handle = int
10
+
11
+ func sys_dup (oldfd Handle ) (Handle , error ) {
12
+ return syscall .Dup (oldfd )
13
+ }
Original file line number Diff line number Diff line change
1
+ //go:build windows
2
+
3
+ package cmdio
4
+
5
+ import (
6
+ "syscall"
7
+
8
+ "golang.org/x/sys/windows"
9
+ )
10
+
11
+ type Handle = syscall.Handle
12
+
13
+ func sys_dup (oldfd Handle ) (Handle , error ) {
14
+ currentProcess := windows .CurrentProcess ()
15
+ var newFdHandle windows.Handle
16
+
17
+ var hSourceProcessHandle = currentProcess
18
+ var hSourceHandle = windows .Handle (oldfd )
19
+ var hTargetProcessHandle = currentProcess
20
+ var lpTargetHandle = & newFdHandle
21
+ var dwDesiredAccess uint32 = 0
22
+ var bInheritHandle = false
23
+ var dwOptions uint32 = windows .DUPLICATE_SAME_ACCESS
24
+
25
+ err := windows .DuplicateHandle (
26
+ hSourceProcessHandle ,
27
+ hSourceHandle ,
28
+ hTargetProcessHandle ,
29
+ lpTargetHandle ,
30
+ dwDesiredAccess ,
31
+ bInheritHandle ,
32
+ dwOptions ,
33
+ )
34
+ if err != nil {
35
+ return 0 , err
36
+ }
37
+
38
+ return Handle (newFdHandle ), nil
39
+ }
Original file line number Diff line number Diff line change 1
1
module github.com/l4go/cmdio
2
2
3
- go 1.15
3
+ go 1.19
4
+
5
+ require (
6
+ github.com/l4go/task v1.20220225.0
7
+ golang.org/x/sys v0.22.0
8
+ )
Original file line number Diff line number Diff line change
1
+ github.com/l4go/task v1.20220225.0 h1:CpAsxaMbcqtikq4qjUposmCDLBACXXLu26J6ocOKzKs =
2
+ github.com/l4go/task v1.20220225.0 /go.mod h1:5vuq2+n3+gYolXbT3AgPaHoCzLDnOLp4NrvWWB1uPV4 =
3
+ github.com/l4go/timer v1.20220131.0 /go.mod h1:3WVqLwRVS1odYYP2UqSs8k8VYAbIRlNEGE02Yq1I2Pw =
4
+ golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI =
5
+ golang.org/x/sys v0.22.0 /go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA =
You can’t perform that action at this time.
0 commit comments