Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 485952 - <=sys-process/procps-3.3.8 top: Write error when using pipes
Summary: <=sys-process/procps-3.3.8 top: Write error when using pipes
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo's Team for Core System packages
URL: https://gitorious.org/procps/procps/c...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-25 09:19 UTC by Florian "adlerweb" Knodt
Modified: 2013-10-25 13:03 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian "adlerweb" Knodt 2013-09-25 09:19:34 UTC
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
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-10-25 11:05:49 UTC
*** Bug 484554 has been marked as a duplicate of this bug. ***
Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-10-25 13:03:52 UTC
+*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.
+