Handle stdin and stderr