File: sys_unix.go

package info (click to toggle)
elvish 0.12%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,532 kB
  • sloc: python: 108; makefile: 94; sh: 72; xml: 9
file content (26 lines) | stat: -rw-r--r-- 423 bytes parent folder | download
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
// +build !windows
// +build !plan9

package daemon

import (
	"os"
	"syscall"

	"golang.org/x/sys/unix"
)

func setUmask() {
	unix.Umask(0077)
}

func procAttrForSpawn() *os.ProcAttr {
	return &os.ProcAttr{
		Dir:   "/",        // cd to /
		Env:   []string{}, // empty environment
		Files: []*os.File{os.Stdin, os.Stdout, os.Stderr},
		Sys: &syscall.SysProcAttr{
			Setsid: true, // detach from current terminal
		},
	}
}