rotate stdin and stdout