in reply to syscall() closes file descriptor
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: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: syscall() closes file descriptor
by starbolin (Hermit) on Aug 22, 2006 at 21:47 UTC | |
by betterworld (Curate) on Aug 22, 2006 at 23:50 UTC | |
by starbolin (Hermit) on Aug 23, 2006 at 03:05 UTC | |
by starbolin (Hermit) on Aug 23, 2006 at 04:14 UTC |