On 02/13/2012 03:31 PM, Pádraig Brady wrote: > On 02/13/2012 02:28 PM, Bernhard Voelker wrote: >> >> >> On 02/13/2012 02:09 PM, Pádraig Brady wrote: >>>> BTW: shouldn't >>>>> echo abcdefghijklm | src/dd bs=5 seek=8 oflag=seek_bytes >>>>> receive EPIPE? When run on a terminal, dd waits in read() forever. >>> True. That's because we try to seek using read() >>> on non seekable files, and stdout is readable by default, >>> so we'll hang waiting for input from the terminal. >>> I.E. this will block: >>> >>> dd seek=1 if=/dev/null >>> >>> Not sure what to do there. > > In other words, I'm not sure this is an issue > >> >> Hmm, the process writing into the pipe has already exited, >> so I don't get why read() doesn't return eof. >> >> Using O_NONBLOCK if reading from stdin? >> Strangely, using iflag=nonblock also blocks ;-( >> >> echo abcdefghijklm | src/dd bs=5 seek=8 iflag=nonblock > > seek is for output, skip is for input.
Now, I see it: it's reading from *stdout*, not from stdin: lseek(1, 0, SEEK_END) = -1 ESPIPE (Illegal seek) read(1, 0x616000, 512) = ? It could issue an error if "seek=..." is used when fdesc is a tty. Have a nice day, Berny
