coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dd: add 'skip_bytes' and 'count_bytes' operands


From: Bernhard Voelker
Subject: Re: dd: add 'skip_bytes' and 'count_bytes' operands
Date: Mon, 13 Feb 2012 16:06:17 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120129 Thunderbird/10.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]