-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysproc_windows.go
More file actions
62 lines (54 loc) · 1.5 KB
/
sysproc_windows.go
File metadata and controls
62 lines (54 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//go:build windows
package execx
import "syscall"
// Setpgid is a no-op on Windows; on Unix it places the child in a new process group.
// @group OS Controls
func (c *Cmd) Setpgid(_ bool) *Cmd {
return c
}
// Setsid is a no-op on Windows; on Unix it starts a new session.
// @group OS Controls
func (c *Cmd) Setsid(_ bool) *Cmd {
return c
}
// Pdeathsig is a no-op on non-Linux platforms; on Linux it signals the child when the parent exits.
// @group OS Controls
func (c *Cmd) Pdeathsig(_ syscall.Signal) *Cmd {
return c
}
// CreationFlags sets Windows process creation flags (for example, create a new process group).
// @group OS Controls
//
// Common flags: execx.CreateNewProcessGroup, execx.CreateNewConsole, execx.CreateNoWindow.
//
// Example: creation flags
//
// out, _ := execx.Command("printf", "ok").CreationFlags(execx.CreateNewProcessGroup).Output()
// fmt.Print(out)
// // ok
func (c *Cmd) CreationFlags(flags uint32) *Cmd {
c.ensureSysProcAttr()
c.sysProcAttr.CreationFlags = flags
return c
}
// HideWindow hides console windows and sets CREATE_NO_WINDOW for console apps.
// @group OS Controls
//
// Example: hide window
//
// out, _ := execx.Command("printf", "ok").HideWindow(true).Output()
// fmt.Print(out)
// // ok
func (c *Cmd) HideWindow(on bool) *Cmd {
c.ensureSysProcAttr()
c.sysProcAttr.HideWindow = on
if on {
c.sysProcAttr.CreationFlags |= syscall.CREATE_NO_WINDOW
}
return c
}
func (c *Cmd) ensureSysProcAttr() {
if c.sysProcAttr == nil {
c.sysProcAttr = &syscall.SysProcAttr{}
}
}