aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/wc.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix/wc.c')
-rw-r--r--toys/posix/wc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/posix/wc.c b/toys/posix/wc.c
index 62d1f7a0..e7afc813 100644
--- a/toys/posix/wc.c
+++ b/toys/posix/wc.c
@@ -53,8 +53,8 @@ static void do_wc(int fd, char *name)
if (toys.optflags == FLAG_c) {
struct stat st;
- fstat(fd, &st);
- if (S_ISREG(st.st_mode)) {
+ // On Linux, files in /proc often report their size as 0.
+ if (!fstat(fd, &st) && S_ISREG(st.st_mode) && st.st_size > 0) {
lengths[2] = st.st_size;
goto show;
}