watchrun icon indicating copy to clipboard operation
watchrun copied to clipboard

Use pty to avoid buffering

Open egonelbre opened this issue 7 years ago • 0 comments

When starting some programs using exec.Cmd it will start them as buffering. Which means you don't see the live-output from the program.

When you have access to the source, this can be changed with:

// #include <stdio.h>
// #include <errno.h>
import "C"

func init() { C.setvbuf(C.stdout, nil, C._IONBF, 0) }

However it's possible to use something like https://github.com/kr/pty to avoid this problem. kr/pty doesn't have Windows support, but based on https://www.codeproject.com/Articles/16163/Real-Time-Console-Output-Redirection and https://gist.github.com/zhangyoufu/be36035e94b8c0dcb1239a3c8b07a3b1... it should be possible to implement them.

egonelbre avatar Mar 06 '18 22:03 egonelbre