/dev/urandom maximum size
If you want to read N bytes guaranteed from /dev/urandom, is it safe to perform a single read call and be guaranteed you get N bytes - or are there some operating systems that don't provide that guarantee, and may pr开发者_如何学运维oduce a short read from /dev/urandom?
A read from /dev/urandom
may return before being fully satisfied if interrupted by a signal.
To be safe, I would not assume that full reads are guaranteed, and instead read repeatedly until you have as much data as you need. You never know when some implementation is going to decide that short reads from /dev/urandom
are fine.
精彩评论