The problem is that syscall.ph doesn't understand what you are trying to do with $f. Perl is passing a GLOB to syscall but it is not getting converted to an address. That is why your output prints "GLOB(0x814".
Note that h2ph ( and thus, syscall.ph )does not claim to handle all structures correctly.
From man h2ph:
" It (h2ph) doesn't handle all C constructs, but it does attempt to isolate definitions inside evals so that you can get at the definitions that it can translate. It's only intended as a rough tool. You may need to dicker with the files produced."
If your read your data into a buffer and pass the buffer then SYS_write works correctly.
Update: Removed extraneous DATA block.#!/usr/bin/perl use strict; use warnings; require 'sys/syscall.ph'; my $file = 'foobar'; my $buffer; open my $f, '<', \$file or die "open: $!"; defined read($f, $buffer, 10) or die "read: $!"; syscall(&SYS_write, fileno(STDERR), $buffer, 10) != -1 or warn "write: + $!"; print STDERR "\n"; defined read($f, $buffer, 1) or die "read: $!";
In reply to Re: syscall() closes file descriptor
by starbolin
in thread syscall() closes file descriptor
by betterworld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |