Created
September 23, 2013 16:14
-
-
Save kwmt/6672954 to your computer and use it in GitHub Desktop.
os.StartProcessの使い方
【参考】
https://groups.google.com/d/msg/golang-nuts/FAiqMVDX1xc/1rnudJ-TZKsJ
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 characters
package main | |
import "os" | |
func main() { | |
if len(os.Args) < 2 { | |
println("usage: %s program arg1 arg2 ...", os.Args[0]) | |
return | |
} | |
var procAttr os.ProcAttr | |
procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} | |
process, err := os.StartProcess(os.Args[1], os.Args[1:], &procAttr) | |
if err != nil { | |
println("start process failed:" + err.Error()) | |
return | |
} | |
_, err = process.Wait() | |
if err != nil { | |
println("Wait Error:" + err.Error()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment