]> granicus.if.org Git - python/commitdiff
Issue #11650: PyOS_StdioReadline() retries fgets() if it was interrupted
authorVictor Stinner <victor.stinner@haypocalc.com>
Sat, 9 Apr 2011 13:55:44 +0000 (15:55 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sat, 9 Apr 2011 13:55:44 +0000 (15:55 +0200)
(EINTR), for example if the program is stopped with CTRL+z on Mac OS X. Patch
written by Charles-Francois Natali.

Misc/NEWS
Parser/myreadline.c

index 2d1327cb3144e28af06834088afff0995e01aad7..895e50d6fa416004c7e3a9db06f2d27c6cf9929d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,10 @@ What's New in Python 3.1.4?
 Core and Builtins
 -----------------
 
+- Issue #11650: PyOS_StdioReadline() retries fgets() if it was interrupted
+  (EINTR), for example if the program is stopped with CTRL+z on Mac OS X. Patch
+  written by Charles-Francois Natali.
+
 - Issue #8651: PyArg_Parse*() functions raise an OverflowError if the file
   doesn't have PY_SSIZE_T_CLEAN define and the size doesn't fit in an int
   (length bigger than 2^31-1 bytes).
index a62e208a72c12b885bdf0483f29ec7983e815bc5..7166fc1d010611fb663e25144fdb4f9f712fe7e4 100644 (file)
@@ -36,7 +36,7 @@ static int
 my_fgets(char *buf, int len, FILE *fp)
 {
     char *p;
-    for (;;) {
+    while (1) {
         if (PyOS_InputHook != NULL)
             (void)(PyOS_InputHook)();
         errno = 0;
@@ -85,9 +85,10 @@ my_fgets(char *buf, int len, FILE *fp)
 #ifdef WITH_THREAD
             PyEval_SaveThread();
 #endif
-            if (s < 0) {
-                return 1;
-            }
+            if (s < 0)
+                    return 1;
+            /* try again */
+            continue;
         }
 #endif
         if (PyOS_InterruptOccurred()) {