[go-nuts] Re: How to capture stderr/stdout of cgo calls?

2016-07-25 Thread Uli Kunitz
Your program doesn't work because changing os.Stdout and os.Stdin has no effect on stdio stdin and stdout. Stdio stdout will still reference fd 1 and stderr fd 2. I recommend following three solutions: 1. The simplest approach could be not to use cgo at all and run the C code in a sepa

[go-nuts] Re: How to capture stderr/stdout of cgo calls?

2016-08-04 Thread Markus Zimmermann
I feared that there would be no pure Go solution. Anyway, I used fdopen variant the code is here https://github.com/zimmski/osutil/blob/master/capture.go#L51 if anyone every stumbles over this thread. Thanks for the help. On Monday, July 25, 2016 at 1:00:46 PM UTC+2, Uli Kunitz wrote: > > Your

[go-nuts] Re: How to capture stderr/stdout of cgo calls?

2016-08-04 Thread mattn
I guess calling freopen is better because cgo possibly having reference of stdin/stdout as FILE*. On Thursday, August 4, 2016 at 8:07:40 PM UTC+9, Markus Zimmermann wrote: > > I feared that there would be no pure Go solution. Anyway, I used fdopen > variant the code is here > https://github.co

[go-nuts] Re: How to capture stderr/stdout of cgo calls?

2016-08-05 Thread Markus Zimmermann
The documentaton says that freopen closes the original stream. Wouldn't that mean, that it is not possible to restore the origianl stderr/stdout? On Friday, August 5, 2016 at 4:52:57 AM UTC+2, mattn wrote: > > I guess calling freopen is better because cgo possibly having reference of > stdin/std

Re: [go-nuts] Re: How to capture stderr/stdout of cgo calls?

2016-08-04 Thread Seb Binet
On Thu, Aug 4, 2016 at 1:07 PM, Markus Zimmermann wrote: > I feared that there would be no pure Go solution. Anyway, I used fdopen > variant the code is here https://github.com/zimmski/ > osutil/blob/master/capture.go#L51 if anyone every stumbles over this > thread. > seems to me like you're lea

Re: [go-nuts] Re: How to capture stderr/stdout of cgo calls?

2016-08-04 Thread Markus Zimmermann
You are right Sebastien, I fixed that. Thanks! On Thursday, August 4, 2016 at 6:58:06 PM UTC+2, Sebastien Binet wrote: > > > > On Thu, Aug 4, 2016 at 1:07 PM, Markus Zimmermann > wrote: > >> I feared that there would be no pure Go solution. Anyway, I used fdopen >> variant the code is here >> h