Skip to content
This repository was archived by the owner on Dec 13, 2022. It is now read-only.

Commit 8c3df38

Browse files
committed
Switch back to exec syscall.
1 parent b6ac423 commit 8c3df38

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

main.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,19 @@ func main() {
101101
case <-time.After(next.Sub(now)):
102102
}
103103

104-
// Run command if specified
104+
// Replace current process if command is specified
105105
args := flag.Args()
106-
if len(args) > 0 {
107-
cmd := exec.Command(args[0], args[1:]...)
108-
cmd.Stdout = os.Stdout
109-
cmd.Stderr = os.Stderr
110-
if err := cmd.Run(); err != nil {
111-
fmt.Fprintln(os.Stderr, err)
112-
}
106+
if len(args) == 0 {
107+
return
108+
}
109+
cmd, err := exec.LookPath(args[0])
110+
if err != nil {
111+
fmt.Fprintln(os.Stderr, err)
112+
os.Exit(1)
113+
}
114+
err = syscall.Exec(cmd, args, os.Environ())
115+
if err != nil {
116+
fmt.Fprintln(os.Stderr, err)
117+
os.Exit(1)
113118
}
114119
}

0 commit comments

Comments
 (0)