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
>> https://github.com/zimmski/osutil/blob/master/capture.go#L51 if anyone
>> every stumbles over this thread.
>>
>
> seems to me like you're leaking C.CString("w") at:
> https://github.com/zimmski/osutil/blob/master/capture.go#L64
>
> it's allocated from cgo so you need to:
> cw := C.CString("w")
> defer C.free(unsafe.Pointer(cw))
> // ...
>
> -s
>
>
>>
>> Thanks for the help.
>>
>>
>> On Monday, July 25, 2016 at 1:00:46 PM UTC+2, Uli Kunitz wrote:
>>>
>>> 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 separate process. Capturing the output of a separate process
>>> is
>>>simple and can be done using the os/exec package.
>>>2. Reset stdin and stdout using fdopen in the C code. This could be
>>>done permanently.
>>>3. Swap file descriptors using dup2.
>>>
>>>
>>>
>>>
>>>
>> --
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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.