File: sys_windows.go

package info (click to toggle)
elvish 0.21.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,372 kB
  • sloc: javascript: 236; sh: 130; python: 104; makefile: 88; xml: 9
file content (30 lines) | stat: -rw-r--r-- 878 bytes parent folder | download | duplicates (2)
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
package daemon

import (
	"os"
	"syscall"
)

// https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
var errConnRefused = syscall.Errno(10061)

// No-op on Windows.
func setUmaskForDaemon() {}

// A subset of possible process creation flags, value taken from
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863(v=vs.85).aspx
const (
	createBreakwayFromJob = 0x01000000
	createNewProcessGroup = 0x00000200
	detachedProcess       = 0x00000008
	daemonCreationFlags   = createBreakwayFromJob | createNewProcessGroup | detachedProcess
)

func procAttrForSpawn(files []*os.File) *os.ProcAttr {
	return &os.ProcAttr{
		Dir:   `C:\`,
		Env:   []string{"SystemRoot=" + os.Getenv("SystemRoot")}, // SystemRoot is needed for net.Listen for some reason
		Files: files,
		Sys:   &syscall.SysProcAttr{CreationFlags: daemonCreationFlags},
	}
}