Hi,

Using `openssl rand' with version 0.9.8g-16ubuntu3.1 I find it ignores
SIGPIPE.

    $ strace -s 3 -e write openssl rand 40960 |
    > dd bs=1 count=1 of=/dev/null
    write(1, "Tgz"..., 4096)                = 4096
    write(1, "e\214\252"..., 4096)          = 4096
    write(1, "\202\244\343"..., 4096)       = 4096
    write(1, "k\21\16"..., 4096)            = 4096
    write(1, "\27\342\340"..., 4096)        = 4096
    write(1, "\4b\26"..., 4096)             = 4096
    write(1, "ZS\273"..., 4096)             = 4096
    1+0 records in
    1+0 records out
    1 byte (1 B) copied, 0.01789 s, 0.1 kB/s
    write(1, "\341\341\200"..., 4096)       = -1 EPIPE (Broken pipe)
    --- SIGPIPE (Broken pipe) @ 0 (0) ---
    write(1, "x\214\30"..., 4096)           = -1 EPIPE (Broken pipe)
    --- SIGPIPE (Broken pipe) @ 0 (0) ---
    write(3, "hz\21"..., 1024)              = 1024
    $ 

This means I can't do

    while openssl rand $bignum; :; done |
    dd bs=4096 of=/dev/foo

The first invocation of openssl can take ages writing the remaining
$bignum bytes to a closed pipe and then, because openssl hasn't left the
default action of SIGPIPE, terminate, in place it exits without error
and the while-loop starts it again.

What's the thinking behind this undocumented behaviour?  It lessens the
utility of the command and makes it an ill-fit for the Unix way of doing
things.

Cheers,
Ralph.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to