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

Commit

Permalink
Switch back to exec syscall.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorinvo committed Jan 17, 2017
1 parent b6ac423 commit 8c3df38
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,19 @@ func main() {
case <-time.After(next.Sub(now)):
}

// Run command if specified
// Replace current process if command is specified
args := flag.Args()
if len(args) > 0 {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
}
if len(args) == 0 {
return
}
cmd, err := exec.LookPath(args[0])
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
err = syscall.Exec(cmd, args, os.Environ())
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}

0 comments on commit 8c3df38

Please sign in to comment.