elvish/pkg/daemon/sys_unix.go
Qi Xiao 101576471b pkg/daemon: Fix the handling of hanging sockets.
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.
2021-10-01 23:56:57 +01:00

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
},
}
}