Perl allows this with its syscall
function:
$ perldoc -f syscall
syscall NUMBER, LIST
Calls the system call specified as the first element of the list,
passing the remaining elements as arguments to the system call. If
⋮
The documentation also gives an example of calling write(2):
require 'syscall.ph'; # may need to run h2ph
my $s = "hi there\n";
syscall(SYS_write(), fileno(STDOUT), $s, length $s);
Can't say I've ever used this feature, though. Well, before just now to confirm the example does indeed work.
This appears to work with getrandom
:
$ perl -E 'require "syscall.ph"; $v = " "x8; syscall(SYS_getrandom(), $v, length $v, 0); print $v' | xxd
00000000: 5790 8a6d 714f 8dbe W..mqO..
And if you don't have getrandom in your syscall.ph, then you could use the number instead. It's 318 on my Debian testing (amd64) box. Beware that Linux syscall numbers are architecture-specific.
/dev/urandom
. You can certainly do that from a shell script. – steve yesterday/dev
isn't yet available. But then hard to imagine Perl would be! – derobert yesterday/dev/random
until it unblocks, then read from/dev/urandom
? – bishop 22 hours ago/dev/random
blocked in this way; somebody just told me. So that works, thanks! – joshlf 21 hours ago