Armin Ronacher <[email protected]> added the comment:
The following minimal C code shows how EINTR can be handled:
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#define BUFFER_SIZE 1024
int
main()
{
char buffer[BUFFER_SIZE];
printf("PID = %d\n", getpid());
while (1) {
int rv = fgetc(stdin);
if (rv < 0) {
if (feof(stdin))
break;
if (errno == EINTR)
continue;
printf("Call failed with %d\n", errno);
return 1;
}
else
fputc(rv, stdout);
}
return 0;
}
Test application:
mitsuh...@nausicaa:/tmp$ ./a.out
PID = 22806
Terminated
mitsuh...@nausicaa:/tmp$ ./a.out
PID = 22809
mitsuh...@nausicaa:/tmp$ ./a.out
PID = 22812
^Z
[2]+ Stopped ./a.out
mitsuh...@nausicaa:/tmp$ fg
./a.out
test
test
foo
foo
First signal sent was TERM, second was INT. Last case was sending to
background, receiving the ignored SIGCONT signal, fgetc returning -1 and fgetc
being called again because of errno being EINTR.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9867>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com