create process group for shell-pipe and shell-async (#753)

This commit is contained in:
Christian Zangl authored and GitHub committed 2022-02-13 23:39:49 +03:00
1 parent 3e3a4a6386
commit c5bd676c3a
6 files changed
+47 -14

No files matched your search

+13 -6
View File
@@ -2,13 +2,13 @@ package main
import (
"fmt"
"golang.org/x/sys/windows"
"log"
"os"
"os/exec"
"os/user"
"path/filepath"
"strings"
"syscall"
)
var (
@@ -87,7 +87,7 @@ func init() {
func detachedCommand(name string, arg ...string) *exec.Cmd {
cmd := exec.Command(name, arg...)
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 8}
cmd.SysProcAttr = &windows.SysProcAttr{CreationFlags: 8}
return cmd
}
@@ -99,6 +99,13 @@ func shellCommand(s string, args []string) *exec.Cmd {
return exec.Command(gOpts.shell, args...)
}
func shellSetPG(cmd *exec.Cmd) {
}
func shellKill(cmd *exec.Cmd) error {
return cmd.Process.Kill()
}
func setDefaults() {
gOpts.cmds["open"] = &execExpr{"&", "%OPENER% %f%"}
gOpts.keys["e"] = &execExpr{"$", "%EDITOR% %f%"}
@@ -123,15 +130,15 @@ func isExecutable(f os.FileInfo) bool {
}
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
ptr, err := syscall.UTF16PtrFromString(filepath.Join(path, f.Name()))
ptr, err := windows.UTF16PtrFromString(filepath.Join(path, f.Name()))
if err != nil {
return false
}
attrs, err := syscall.GetFileAttributes(ptr)
attrs, err := windows.GetFileAttributes(ptr)
if err != nil {
return false
}
return attrs&syscall.FILE_ATTRIBUTE_HIDDEN != 0
return attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0
}
func userName(f os.FileInfo) string {
@@ -147,7 +154,7 @@ func linkCount(f os.FileInfo) string {
}
func errCrossDevice(err error) bool {
return err.(*os.LinkError).Err.(syscall.Errno) == 17
return err.(*os.LinkError).Err.(windows.Errno) == 17
}
func exportFiles(f string, fs []string, pwd string) {