detach server on windows

Related #106
This commit is contained in:
Gokcehan committed 2018-08-01 00:21:55 +03:00
1 parent d3f9a3588f
commit 0b8de7c77e
3 files changed
+13 -3

No files matched your search

+2 -3
View File
@@ -6,14 +6,13 @@ import (
"log"
"net"
"os"
"os/exec"
"path/filepath"
"runtime"
"runtime/pprof"
)
var (
envPath = os.Getenv("PATH")
envPath = os.Getenv("PATH")
envLevel = os.Getenv("LF_LEVEL")
)
@@ -42,7 +41,7 @@ func init() {
}
func startServer() {
cmd := exec.Command(os.Args[0], "-server")
cmd := detachedCommand(os.Args[0], "-server")
if err := cmd.Start(); err != nil {
log.Printf("starting server: %s", err)
}
+4
View File
@@ -80,6 +80,10 @@ func init() {
gDefaultSocketPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.sock", gUser.Username))
}
func detachedCommand(name string, arg ...string) *exec.Cmd {
return exec.Command(name, arg...)
}
func pauseCommand() *exec.Cmd {
cmd := `echo
echo -n 'Press any key to continue'
+7
View File
@@ -7,6 +7,7 @@ import (
"os/user"
"path/filepath"
"strings"
"syscall"
)
var (
@@ -70,6 +71,12 @@ func init() {
gHistoryPath = filepath.Join(data, "lf", "history")
}
func detachedCommand(name string, arg ...string) *exec.Cmd {
cmd := exec.Command(name, arg...)
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 8}
return cmd
}
func pauseCommand() *exec.Cmd {
return exec.Command("cmd", "/c", "pause")
}