mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
101576471b
Also enable the test. The implementation incorrectly assumed that trying to connect to a hanging socket will return rpc.ErrShutdown; this is not actually the case. Also change error wrapping in activate.go to use %w instead of %v to preserve the wrapped error.
28 lines
525 B
Go
28 lines
525 B
Go
//go:build !windows && !plan9 && !js
|
|
// +build !windows,!plan9,!js
|
|
|
|
package daemon
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
var errConnRefused = syscall.ECONNREFUSED
|
|
|
|
// Make sure that files created by the daemon is not accessible to other users.
|
|
func setUmaskForDaemon() { unix.Umask(0077) }
|
|
|
|
func procAttrForSpawn(files []*os.File) *os.ProcAttr {
|
|
return &os.ProcAttr{
|
|
Dir: "/",
|
|
Env: []string{},
|
|
Files: files,
|
|
Sys: &syscall.SysProcAttr{
|
|
Setsid: true, // detach from current terminal
|
|
},
|
|
}
|
|
}
|