add function to use as goroutine for stdout and stderr pipes