> Supposed to just print the first line?, instead, it prints:
> 
> read: error reading /mnt/wsys/wctl: buffer too small
> 
> Several guys from #plan9 in Freenode told me that that was happening
> because of a missing newline.

not correct.  it is happening because rio thinks the read
requests too few bytes.  sys/src/cmd/rio/xfid.c:791,796.
read reads 1 byte at a time.  it's not clear that read(5)
expressly allows rio to error here, but it seems reasonable enough.
read(1) uses realloc to allocate its buffer and would hang
looking for a newline if rio allowed 1 byte reads.  if
/mnt/wsys/wctl produced a stream of output with no
newlines, read would eventually fail like this

; time read</dev/zero 
read: malloc error: virtual memory allocation failed
156.51u 757.95s 916.67r          read  # status= malloc

> But, is the current behavior correct? Or is it erroneous?

while correct and consistent, a newline might have made life
a tad easier for shell scripts.

- erik

Reply via email to