When using top (tested 3.3.6,3.3.8) in combination with pipes it may exit with "top: write error" if the pipe is closed before top itself has exited. Upstream-Patch available at https://gitorious.org/procps/procps/commit/ce5e995921e770bfcda25e42fe090aeccdbf1291. Reproducible: Always Steps to Reproduce: 1. top -bn1 | head -n10 Actual Results: top - 09:04:10 up 2 days, 13:15, 1 user, load average: 1.18, 1.57, 1.43 top: write error Expected Results: top - 09:04:10 up 2 days, 13:15, 1 user, load average: 1.18, 1.57, 1.43 (no further error message) strace: [...] write(1, "%Cpu0 : 23.3 us, 3.5 sy, 3.0 "..., 4096) = -1 EPIPE (Broken pipe) --- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=4196, si_uid=0} --- rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], NULL, 8) = 0 write(1, "%Cpu0 : 23.3 us, 3.5 sy, 3.0 "..., 4096) = -1 EPIPE (Broken pipe) close(1) = 0 munmap(0x7fea8fb79000, 4096) = 0 write(2, "top: ", 5top: ) = 5 write(2, "write error", 11write error) = 11 write(2, "\n", 1 ) = 1 exit_group(1) = ? +++ exited with 1 +++ ---snip--- procps USE="ncurses nls unicode -static-libs" ---snip--- Basic Workarround: top -bn1 2>/dev/null | head -n1
*** Bug 484554 has been marked as a duplicate of this bug. ***
+*procps-3.3.8-r1 (25 Oct 2013) + + 25 Oct 2013; Lars Wendler <polynomial-c@gentoo.org> +procps-3.3.8-r1.ebuild: + Fixed write error when using top with pipes. Thanks to Florian Knodt for + reporting this in bug #485952. +