Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9175c3d8
Kaydet (Commit)
9175c3d8
authored
Haz 29, 2012
tarafından
Tim Golden
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #1677: Handle better a race condition between the interactive interpreter and
the Ctrl-C signal handler on Windows
üst
25652884
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
23 deletions
+22
-23
myreadline.c
Parser/myreadline.c
+22
-23
No files found.
Parser/myreadline.c
Dosyayı görüntüle @
9175c3d8
...
@@ -35,6 +35,9 @@ int (*PyOS_InputHook)(void) = NULL;
...
@@ -35,6 +35,9 @@ int (*PyOS_InputHook)(void) = NULL;
static
int
static
int
my_fgets
(
char
*
buf
,
int
len
,
FILE
*
fp
)
my_fgets
(
char
*
buf
,
int
len
,
FILE
*
fp
)
{
{
#ifdef MS_WINDOWS
HANDLE
hInterruptEvent
;
#endif
char
*
p
;
char
*
p
;
int
err
;
int
err
;
while
(
1
)
{
while
(
1
)
{
...
@@ -50,32 +53,28 @@ my_fgets(char *buf, int len, FILE *fp)
...
@@ -50,32 +53,28 @@ my_fgets(char *buf, int len, FILE *fp)
return
0
;
/* No error */
return
0
;
/* No error */
err
=
errno
;
err
=
errno
;
#ifdef MS_WINDOWS
#ifdef MS_WINDOWS
/* In the case of a Ctrl+C or some other external event
/* Ctrl-C anywhere on the line or Ctrl-Z if the only character
interrupting the operation:
on a line will set ERROR_OPERATION_ABORTED. Under normal
Win2k/NT: ERROR_OPERATION_ABORTED is the most recent Win32
circumstances Ctrl-C will also have caused the SIGINT handler
error code (and feof() returns TRUE).
to fire which will have set the event object returned by
Win9x: Ctrl+C seems to have no effect on fgets() returning
_PyOS_SigintEvent. This signal fires in another thread and
early - the signal handler is called, but the fgets()
is not guaranteed to have occurred before this point in the
only returns "normally" (ie, when Enter hit or feof())
code.
Therefore: check whether the event is set with a small timeout.
If it is, assume this is a Ctrl-C and reset the event. If it
isn't set assume that this is a Ctrl-Z on its own and drop
through to check for EOF.
*/
*/
if
(
GetLastError
()
==
ERROR_OPERATION_ABORTED
)
{
if
(
GetLastError
()
==
ERROR_OPERATION_ABORTED
)
{
/* Signals come asynchronously, so we sleep a brief
hInterruptEvent
=
_PyOS_SigintEvent
();
moment before checking if the handler has been
switch
(
WaitForSingleObject
(
hInterruptEvent
,
10
))
{
triggered (we cant just return 1 before the
case
WAIT_OBJECT_0
:
signal handler has been called, as the later
ResetEvent
(
hInterruptEvent
);
signal may be treated as a separate interrupt).
*/
Sleep
(
1
);
if
(
PyOS_InterruptOccurred
())
{
return
1
;
/* Interrupt */
return
1
;
/* Interrupt */
case
WAIT_FAILED
:
return
-
2
;
/* Error */
}
}
/* Either the sleep wasn't long enough (need a
short loop retrying?) or not interrupted at all
(in which case we should revisit the whole thing!)
Logging some warning would be nice. assert is not
viable as under the debugger, the various dialogs
mean the condition is not true.
*/
}
}
#endif
/* MS_WINDOWS */
#endif
/* MS_WINDOWS */
if
(
feof
(
fp
))
{
if
(
feof
(
fp
))
{
...
@@ -94,7 +93,7 @@ my_fgets(char *buf, int len, FILE *fp)
...
@@ -94,7 +93,7 @@ my_fgets(char *buf, int len, FILE *fp)
#endif
#endif
if
(
s
<
0
)
if
(
s
<
0
)
return
1
;
return
1
;
/* try again */
/* try again */
continue
;
continue
;
}
}
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment