On Tue, 22 Mar 2016, Richard PALO wrote: > What I'm seeing is an infinite loop of the following (using /usr/bin/head): > > 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
Hmm, if I had to hazard a guess, I say that head is using the return value from either strlen() or printf() to count the number of characters. Given an infinite stream of zeros, both of these functions would always return 0, so head's termination claues of 1 character (-c 1) is never met. I'd say it's a bug in head, which should presumably use the return value from read() to keep track of how many bytes it has read. -- Rich Teer, Publisher Vinylphile Magazine www.vinylphilemag.com ------------------------------------------- illumos-discuss Archives: https://www.listbox.com/member/archive/182180/=now RSS Feed: https://www.listbox.com/member/archive/rss/182180/21175430-2e6923be Modify Your Subscription: https://www.listbox.com/member/?member_id=21175430&id_secret=21175430-6a77cda4 Powered by Listbox: http://www.listbox.com