Last active
August 25, 2019 07:31
Revisions
-
suzuki-shunsuke revised this gist
Aug 25, 2019 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ func main() { cmd := exec.Command("sh", "-c", "ls | fzf") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr // it works as expected. if err := cmd.Run(); err != nil { fmt.Println(err) } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ func main() { KillAfter: 5 * time.Second, // Foreground: true, } // it doesn't work as expected. exitStatus, err := tio.RunContext(context.Background()) fmt.Println(exitStatus, err) } -
suzuki-shunsuke created this gist
Aug 25, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ package main import ( "fmt" "os" "os/exec" ) func main() { cmd := exec.Command("sh", "-c", "ls | fzf") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr // it works as expected. if err := cmd.Run(); err != nil { fmt.Println(err) } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ package main import ( "context" "fmt" "os" "os/exec" "time" "github.com/Songmu/timeout" ) func main() { cmd := exec.Command("sh", "-c", "ls | fzf") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr tio := &timeout.Timeout{ Cmd: cmd, Duration: 10 * time.Second, KillAfter: 5 * time.Second, // Foreground: true, } // it doesn't work as expected. exitStatus, err := tio.RunContext(context.Background()) fmt.Println(exitStatus, err) }