New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POSIX::read and POSIX::write return -1 on error #16347
Comments
From @zmanda-pusher1Created by @zmanda-pusher1POSIX::read return -1 on some error, the documentation say it return undef. Simple program to reproduce:#!/usr/bin/perl -W print "count: $count\n";
|
From @jkeenanOn Tue, 02 Jan 2018 21:09:06 GMT, martineau.jl@gmail.com wrote:
Requesting comment from committer. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @jhiDuh. How about the attached patch? |
From @jhi0001-perl-132677-POSIX-read-and-POSIX-write-return-1-on-e.patchFrom 8053c874e4b4c64370cc07115afdc46cfd8e6b53 Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Wed, 3 Jan 2018 09:25:45 +0200
Subject: [PATCH] [perl #132677] POSIX::read and POSIX::write return -1 on
error
ddc7c5c7d33132a836845f632085f65497425023 wrongly did XSRETURN_IV(-1)
when it should have done XSRETURN_UNDEF.
---
ext/POSIX/t/posix.t | 4 +++-
ext/POSIX/typemap | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/ext/POSIX/t/posix.t b/ext/POSIX/t/posix.t
index 1b2dd4010b..a442ccc544 100644
--- a/ext/POSIX/t/posix.t
+++ b/ext/POSIX/t/posix.t
@@ -10,7 +10,7 @@ BEGIN {
require 'loc_tools.pl';
}
-use Test::More tests => 93;
+use Test::More tests => 94;
use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write
errno localeconv dup dup2 lseek access);
@@ -376,6 +376,8 @@ is($buffer, "# Ex", 'read');
undef $buffer;
read($fd2, $buffer, 4) if $fd2 > 2;
is($buffer, "# Ex", 'read');
+
+ is(read(-1, $buffer, 1), undef, 'read from bad fd');
}
# The FreeBSD man page warns:
diff --git a/ext/POSIX/typemap b/ext/POSIX/typemap
index 753afcd1a5..4808a7fdb1 100644
--- a/ext/POSIX/typemap
+++ b/ext/POSIX/typemap
@@ -39,7 +39,7 @@ T_SIGNO
T_FD
if ((fd = (int)SvIV($arg)) < 0) {
SETERRNO(EBADF, RMS_IFI);
- XSRETURN_IV(-1);
+ XSRETURN_UNDEF;
}
OUTPUT
--
2.14.3
|
From @LeontOn Wed, Jan 3, 2018 at 9:01 AM, Jarkko Hietaniemi <jhi@iki.fi> wrote:
This looks good to me. Some of those functions aren't documented to Leont |
Migrated from rt.perl.org#132677 (status was 'open')
Searchable as RT132677$
The text was updated successfully, but these errors were encountered: