I am not sure that is idiomatic Go. Start a new Go routine to do the reading, and post the results to a channel that the main routine selects on.
> On Oct 14, 2024, at 4:57 PM, Peter Bočan <peppy.bo...@gmail.com> wrote: > > Hello Community, > > I am writing a small binary which watches the subprocesses it launches. > However, I have noticed that cmd.StdoutPipe and cmd.StderrPipe returns > io.ReadCloser/io.File, which also, in itself blocks when reading. > > What is the recommended way of reading whatever is on the buffer and return > back without blocking? It looks like a bit of a rabbit hole. Is setting the > nonblocking flag using syscall recommended? > > Kindly, > Peter. > > -- > 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 > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/71f46bd4-0916-4e1b-8821-17d884d0333an%40googlegroups.com > > <https://groups.google.com/d/msgid/golang-nuts/71f46bd4-0916-4e1b-8821-17d884d0333an%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2BC32103-998D-4413-BF8A-68CAB0620C43%40ix.netcom.com.