homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aronacher
Recipients aronacher, loewis, ned.deily, ronaldoussoren
Date 2010年09月16日.12:34:03
SpamBayes Score 4.7262227e-05
Marked as misclassified No
Message-id <1284640445.49.0.754017666834.issue9867@psf.upfronthosting.co.za>
In-reply-to
Content
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:
mitsuhiko@nausicaa:/tmp$ ./a.out 
PID = 22806
Terminated
mitsuhiko@nausicaa:/tmp$ ./a.out 
PID = 22809
mitsuhiko@nausicaa:/tmp$ ./a.out 
PID = 22812
^Z
[2]+ Stopped ./a.out
mitsuhiko@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.
History
Date User Action Args
2010年09月16日 12:34:05aronachersetrecipients: + aronacher, loewis, ronaldoussoren, ned.deily
2010年09月16日 12:34:05aronachersetmessageid: <1284640445.49.0.754017666834.issue9867@psf.upfronthosting.co.za>
2010年09月16日 12:34:04aronacherlinkissue9867 messages
2010年09月16日 12:34:03aronachercreate

AltStyle によって変換されたページ (->オリジナル) /