Project

General

Profile

Bug #6782

/bin/head experiences issues when accessing /dev/zero

Added by Richard PALO about 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2016-03-22
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

as indicated on illumos@
'head -c 1 /dev/zero |wc -c' just hangs while 'sh -c 'head -c 1 /dev/zero|wc -c' correctly returns '1'

truss reveals a nasty endless loop:

$ truss  -u libc head -c 1 /dev/zero
 ...
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1:    read(3, "\0\0\0\0\0\0\0\0\0\0\0\0".., 8192)    = 8192
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 /1@1:    -> libc:fgets(0x8047680, 0x400, 0x80622b0, 0x0)
 /1@1:    <- libc:fgets() = 0x8047680
 /1@1:    -> libc:strlen()
 /1@1:    <- libc:strlen() = 0
 /1@1:    -> libc:printf()
 /1@1:    <- libc:printf() = 0
 /1@1:    -> libc:fflush(0x8062290, 0x8047680, 0x80622b0, 0x0)
 /1@1:    <- libc:fflush() = 0
 ...

Also available in: Atom PDF