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
select returns -1 but $! is 0 (or empty string) #11160
Comments
From oskar@osk.mine.nuThis is a bug report for perl from oskar@osk.mine.nu, The program shows how select in some situations fails and return -1 but does not set $!. waitpid=0 select=-1 errno=0 (Sometimes waitpid return >0 in which case this bug is not reproduced. Here is the program - I tried to make it as short as possible. #!/usr/bin/perl -w I did some debugging and it seems the select syscall actually /* compile with gcc -shared -o fake_select.so fake_select.c -fPIC */ #define _GNU_SOURCE int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) Regards, Oskar Liljeblad Flags: Site configuration information for perl 5.10.1: Configured by Debian Project at Fri Jan 7 12:14:33 UTC 2011. Summary of my perl5 (revision 5 version 10 subversion 1) configuration: Locally applied patches: @INC for perl 5.10.1: Environment for perl 5.10.1: |
From perl5-porters@ton.iguana.beIn article <rt-3.6.HEAD-28241-1298911559-101.85104-75-0@perl.org>,
This is the annoying result of the way safe signals work. Basically on the However, i don't think you SHOULD have to do this. To my mind perl itself |
The RT System itself - Status changed from 'new' to 'open' |
From perl5-porters@ton.iguana.beIn article <ikiitc$k2b$1@post.home.lunix>,
And here is a patch that saves ========================================================================== Inline Patch
|
From @LeontOn Tue, Mar 1, 2011 at 11:48 AM, Ton Hospel <perl5-porters@ton.iguana.be> wrote:
Actually, blead already does this (see commit Leon |
From @LeontOn Tue, Mar 1, 2011 at 2:29 PM, Ton Hospel <perl5-porters@ton.iguana.be> wrote:
Next time please send a patch against blead, not such an old release Leon |
From perl5-porters@ton.iguana.beIn article <AANLkTimMGcg3qH_8OyShXmiqEcGw9GePTB-butjtRzyy@mail.gmail.com>,
Ah, good. I guess i'll have to start using git to see blead... ...fetching git and a git copy of blead and looking at that commit.... But actually I like my patch (in this same thread) slightly better. Ps: why is the function called Perl_despatch_signals instead of |
From perl5-porters@ton.iguana.beIn article <AANLkTimprXWyhpLz+nRs_Cx2ZYw9tsgCrwDfUVAm7EHD@mail.gmail.com>,
Ok following is the patch against blead. Changes: I have no system where mg.c | 29 ++++++++++++++++++++++++++++- Inline Patchdiff --git a/mg.c b/mg.c
index 7b5fdf5..9f892a3 100644
--- a/mg.c
+++ b/mg.c
@@ -1446,11 +1446,30 @@ void
Perl_despatch_signals(pTHX)
{
dVAR;
+ dSAVEDERRNO;
int sig;
+
+ /* Save $^E by Duplicating some code from Perl_magic_get and Perl_magic_set
+ VAX and unix are already handled by SAVED ERRNO */
+#if defined(MACOS_TRADITIONAL)
+ const short saved_err = gMacPerl_OSErr;
+#elif defined(OS2)
+ int saved_err;
+
+ if ((_emx_env & 0x200) && errno != errno_isOS2) {
+ const int tmp = _syserrno();
+ if (tmp) /* 2nd call to _syserrno() makes it 0 */
+ Perl_rc = tmp;
+ }
+ saved_err = Perl_rc;
+#elif defined(WIN32)
+ const DWORD saved_err = GetLastError();
+#endif
+
+ SAVE_ERRNO;
PL_sig_pending = 0;
for (sig = 1; sig < SIG_SIZE; sig++) {
if (PL_psig_pend[sig]) {
- dSAVE_ERRNO;
#ifdef HAS_SIGPROCMASK
/* From sigaction(2) (FreeBSD man page):
* | Signal routines normally execute with the signal that
@@ -1484,6 +1503,14 @@ Perl_despatch_signals(pTHX)
LEAVE;
#endif
RESTORE_ERRNO;
+#if defined(MACOS_TRADITIONAL)
+ gMacPerl_OSErr = saved_err;
+#elif defined(OS2)
+ Perl_rc = saved_err;
+ os2_setsyserrno(Perl_rc);
+#elif defined(WIN32)
+ SetLastError(saved_err);
+#endif
}
}
}
--
1.7.1 |
From @cpansproutOn Tue Mar 01 07:44:37 2011, perl5-porters@ton.iguana.be wrote:
Your patch uses MACOS_TRADITIONAL. Mac Classic support was removed from
|
From @tonycozOn Tue Mar 01 07:44:37 2011, perl5-porters@ton.iguana.be wrote:
While the patch supplied has some issues, I wonder if dSAVE_ERRNO should Tony |
From @tonycozOn Sun Jun 23 22:50:30 2013, tonyc wrote:
Here's an alternate patch that extends the errno save macros for No tests yet. Tony |
From @tonycoz0001-perl-85104-work-harder-to-save-error-numbers.patchFrom 2b38ee36b8f61351702be32738a3316707bf1c35 Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Mon, 15 Jul 2013 10:42:01 +1000
Subject: [PATCH] [perl #85104] work harder to save error numbers
Updates the errno save macros to save the platform error number where
needed for more than just VMS.
The OS/2 code is untested.
---
perl.h | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/perl.h b/perl.h
index bc8388f..a745c2b 100644
--- a/perl.h
+++ b/perl.h
@@ -1168,12 +1168,6 @@ EXTERN_C char *crypt(const char *, const char *);
# define SS_IVCHAN SS$_IVCHAN
# define SS_NORMAL SS$_NORMAL
#else
-# define SETERRNO(errcode,vmserrcode) (errno = (errcode))
-# define dSAVEDERRNO int saved_errno
-# define dSAVE_ERRNO int saved_errno = errno
-# define SAVE_ERRNO (saved_errno = errno)
-# define RESTORE_ERRNO (errno = saved_errno)
-
# define LIB_INVARG 0
# define RMS_DIR 0
# define RMS_FAC 0
@@ -1188,6 +1182,31 @@ EXTERN_C char *crypt(const char *, const char *);
# define SS_NORMAL 0
#endif
+#ifdef WIN32
+# define dSAVEDERRNO int saved_errno; DWORD saved_win32_errno
+# define dSAVE_ERRNO int saved_errno = errno; DWORD saved_win32_errno = GetLastError()
+# define SAVE_ERRNO ( saved_errno = errno, saved_win32_errno = GetLastError() )
+# define RESTORE_ERRNO ( errno = saved_errno, SetLastError(saved_win32_errno) )
+#endif
+
+#ifdef OS2
+# define dSAVEDERRNO int saved_errno; unsigned long saved_os2_errno
+# define dSAVE_ERRNO int saved_errno = errno; unsigned long saved_os2_errno = Perl_rc
+# define SAVE_ERRNO ( saved_errno = errno, saved_os2_errno = Perl_rc )
+# define RESTORE_ERRNO ( errno = saved_errno, Perl_rc = saved_os2_errno) )
+#endif
+
+#ifndef SETERRNO
+# define SETERRNO(errcode,vmserrcode) (errno = (errcode))
+#endif
+
+#ifndef dSAVEDERRNO
+# define dSAVEDERRNO int saved_errno
+# define dSAVE_ERRNO int saved_errno = errno
+# define SAVE_ERRNO (saved_errno = errno)
+# define RESTORE_ERRNO (errno = saved_errno)
+#endif
+
#define ERRSV GvSVn(PL_errgv)
#define CLEAR_ERRSV() STMT_START { \
--
1.7.10.4
|
From @tonycozOn Sun Jul 14 18:10:49 2013, tonyc wrote:
I've applied a varient of this as Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#85104 (status was 'resolved')
Searchable as RT85104$
The text was updated successfully, but these errors were encountered: