in reply to Re^3: syscall() closes file descriptor
in thread syscall() closes file descriptor
Note: It doesn't matter which routine you call only that the filehandle as a scalar in the argument list. So it seems to be an artifact of Perl trying to munge the argument list into a C structure.
#!/usr/bin/perl use strict; use warnings; require 'sys/syscall.ph'; my $buffer = " "; open my $f, '</dev/null' or die "open: $!"; # This works syscall(&SYS_read, fileno($f), $buffer, 1) != -1 or warn "write: $!"; defined read($f, $buffer, 1) or die "First pass, read: $!"; # This closes $f syscall(&SYS_read, fileno($f), $buffer, 1, $f) != -1 or warn "write: $ +!"; defined read($f, $buffer, 1) or die "Second pass, read: $!";
Since there would be no C function that took a Perl filehandle as an argument, the appearance of a Perl filehandle in a syscall argument list I take to be an error.
|
|---|