bash pipe redirection gets stuck

long at rule.lv long at rule.lv
Mon Dec 3 20:43:42 UTC 2012


> On 03.12.12 15:35, long at rule.lv wrote:
> [...]
>> I stumbled upon a problem where multiple pipe redirection occasionally
>> get
>> stuck when trying to get sha256 sum of a stream.
>>
>> You can try to reproduce the problem if you have /usr/ports/shells/bash
>> installed (output redirection used in this command is possible only in
>> bash).
>> Create temporary test file with command: "dd if=/dev/urandom
>> of=/tmp/file1
>> bs=1k count=10"
>> And the command I'm using is:
>> /usr/local/bin/bash -c 'cat /tmp/file1 | tee >(/sbin/sha256 >
>> /tmp/file1.sha256) > /tmp/file1.copy' ; echo $status
>>
>> Command gets stuck about once in 20 executions.
>> top output when command gets stuck (irrelevant processes removed):
>>    PID USERNAME    THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU
>> COMMAND
>> 84073 HappyUser     1  52    0 17612K  2268K wait    0   0:00  0.00%
>> bash
>> 84154 HappyUser     1  52    0 10084K   844K fifoow  1   0:00  0.00% tee
>>
>> And more strangely, I can reproduce this problem on 9.0-RELEASE and
>> 7.4-RELEASE-p6, but couldn't reproduce on 8.2-RELEASE-p4.
> It maybe couldn't gather more randomness from /dev/random?
> The random(4) manpage suggests that there's (theoretically)
> indeed a chance that it blocks - see the section about
> 'kern.random.sys.seeded'.
> So in fact - when you think the command gets stuck - it's
> probably not bash related at all.
>
> cheers,
> Frank Reppin
>
> --
> 43rd Law of Computing:
>          Anything that can go wr
> fortune: Segmentation violation -- Core dumped
>
>

Thanks for your answer, but randomly generated file is created fine (it is
only for illustrative purpose). As far as I understand, thing that blocks
is tee inside bash command or pipeline.

Thanks and best regards,
Normunds



More information about the freebsd-questions mailing list