Confused by sysread()

Roger Burton West roger at firedrake.org
Tue Apr 10 16:28:14 BST 2012


On Tue, Apr 10, 2012 at 10:51:27AM +0100, Dave Mitchell wrote:

>Unlikely to be the issue, but have you tested doing a single 16-byte read,
>e.g.
>    dd if=/dev/foo of=/dev/null bs=16 count=1

dd: reading `/dev/input/event8': Invalid argument

...but open() doesn't fail, and cat still works.

OK, so it's not something Perl-specific? This is running off the end of
the Unix I know, but there are people I can ask... thanks.

>Try running it with strace, to see what underlying system calls are being
>performed on the file handle.

[...]
select(8, [3 4], NULL, NULL, {0, 500000}) = 0 (Timeout)
select(8, [3 4], NULL, NULL, {0, 500000}) = 0 (Timeout)
select(8, [3 4], NULL, NULL, {0, 500000}) = 1 (in [4], left {0, 490567})
read(4, 0xa2a5e0, 16)                   = -1 EINVAL (Invalid argument)
write(2, "Invalid argument at ./tmp line 5"..., 35) = 35
close(3)                                = 0
close(4)                                = 0
[...]

>If its not obvious from that, then strace
>the working 5.8.x version too to see what's different. 

That would be the version from before the system upgrade; I don't have
any 5.8.x boxes left.

On Tue, Apr 10, 2012 at 11:02:31AM +0100, Dirk Koopman wrote:
> my $y=sysread $fh,$data,16,0;

Makes no difference.

R


More information about the london.pm mailing list