我使用perl和bash对一个简单的脚本进行了strace
。
$ strace perl -e 'echo "test";' 2>&1 | grep 'random'
open("/dev/urandom", O_RDONLY) = 3
$ strace bash 'echo "test"' 2>&1 | grep 'random'
$
为什么Perl需要伪随机数生成器来运行这么简单的脚本?我希望只有在第一次使用随机数据之后才打开/dev/urandom
。
编辑:我也测试了Python和Ruby。
$ strace python -c 'print "test"' 2>&1 | grep random
$
$ strace ruby -e 'print "test\n"' 2>&1 | grep random
open("/dev/urandom", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_CLOEXEC) = 3
为什么Perl和Ruby使用不同的模式打开它?