-
Notifications
You must be signed in to change notification settings - Fork 560
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
[PATCH] win32: sleep() warns and it doesn't really sleep forever #16631
Comments
From @xenuUnder windows, sleep() called with no arguments triggers the following
Additionally, it sleeps for just 4262198 seconds (~50 days) instead of I have implemented win32_pause() which will fix the above problems, the |
From @xenuOn Sat, 14 Jul 2018 17:51:02 -0700
The patch is attached. |
From @xenu0001-win32-fix-argumentless-sleep.patchFrom 6196cf8728a5c10a6d9322b9e71cc7d67d96f4c6 Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Sun, 15 Jul 2018 02:33:16 +0200
Subject: [PATCH 1/1] win32: fix argumentless sleep()
Before this commit, pause() was implemented as a macro calling
win32_sleep((32767L << 16) + 32767), which was causing the following
problems with argumentless sleep():
- it was sleeping for 4262198 seconds (~50 days) instead of forever
- it was triggering "sleep(2147450879) too large" warning
This commit implements pause() as a proper function which calls
win32_msgwait() with an INFINITE timeout.
[perl #133376]
---
makedef.pl | 1 +
win32/perlhost.h | 2 +-
win32/win32.c | 8 ++++++++
win32/win32iop.h | 3 ++-
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/makedef.pl b/makedef.pl
index 661b71de7e..6b97ad0033 100644
--- a/makedef.pl
+++ b/makedef.pl
@@ -898,6 +898,7 @@ if ($ARGS{PLATFORM} =~ /^win(?:32|ce)$/) {
win32_realloc
win32_free
win32_sleep
+ win32_pause
win32_times
win32_access
win32_alarm
diff --git a/win32/perlhost.h b/win32/perlhost.h
index 3260f62a02..6dd269efa7 100644
--- a/win32/perlhost.h
+++ b/win32/perlhost.h
@@ -1605,7 +1605,7 @@ PerlProcKillpg(struct IPerlProc* piPerl, int pid, int sig)
int
PerlProcPauseProc(struct IPerlProc* piPerl)
{
- return win32_sleep((32767L << 16) + 32767);
+ return win32_pause();
}
PerlIO*
diff --git a/win32/win32.c b/win32/win32.c
index c7656c631b..769a0e11b3 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2455,6 +2455,14 @@ win32_sleep(unsigned int t)
return win32_msgwait(aTHX_ 0, NULL, t * 1000, NULL) / 1000;
}
+DllExport int
+win32_pause(void)
+{
+ dTHX;
+ win32_msgwait(aTHX_ 0, NULL, INFINITE, NULL);
+ return -1;
+}
+
DllExport unsigned int
win32_alarm(unsigned int sec)
{
diff --git a/win32/win32iop.h b/win32/win32iop.h
index 842bc073be..a9235d3595 100644
--- a/win32/win32iop.h
+++ b/win32/win32iop.h
@@ -128,6 +128,7 @@ DllExport char* win32_getenv(const char *name);
DllExport int win32_putenv(const char *name);
DllExport unsigned win32_sleep(unsigned int);
+DllExport int win32_pause(void);
DllExport int win32_times(struct tms *timebuf);
DllExport unsigned win32_alarm(unsigned int sec);
DllExport char* win32_longpath(char *path);
@@ -429,7 +430,7 @@ END_EXTERN_C
*/
#define pipe(fd) win32_pipe((fd), 512, O_BINARY)
-#define pause() win32_sleep((32767L << 16) + 32767)
+#define pause win32_pause
#define sleep win32_sleep
#define times win32_times
#define ioctl win32_ioctl
--
2.17.0.windows.1
|
From @tonycozOn Sat, 14 Jul 2018 17:58:58 -0700, me@xenu.pl wrote:
Thanks, applied as bbc9927. Tony |
The RT System itself - Status changed from 'new' to 'open' |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133376 (status was 'resolved')
Searchable as RT133376$
The text was updated successfully, but these errors were encountered: