package main import ( "bytes" "context" "log" "os/exec" "time" )
func main() { var stdout bytes.Buffer ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() cmd := exec.CommandContext(ctx, "/bin/sh", "-c", "sleep 10; echo foo") cmd.Stdout = &stdout err := cmd.Run() log.Printf("%s, %s, '%s'", err, ctx.Err(), stdout.String()) } This runs for 10 seconds, but I was expecting 1 second. Can someone help me understand what is happening? I think it has something to do with the stdout bytes.Buffer? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.