May1911
04-05-2005, 04:43 PM
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
static void empty(int sig)
{
printf ("hello\n");
return;
}
void main()
{
int fd, a;
char buf[512];
if (fd = open("/tmp/nic", O_RDONLY) < 0)
{
perror ("open");
exit(1);
}
signal (SIGALRM, empty);
alarm (1);
a = read(fd, buf, 511);
while (a && a != -1) a = read(fd, buf, 511);
if (a == -1)
{
perror ("read");
exit(1);
}
else printf ("EOF\n");
exit(0);
}
Why isn't there any error Eintr ?
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
static void empty(int sig)
{
printf ("hello\n");
return;
}
void main()
{
int fd, a;
char buf[512];
if (fd = open("/tmp/nic", O_RDONLY) < 0)
{
perror ("open");
exit(1);
}
signal (SIGALRM, empty);
alarm (1);
a = read(fd, buf, 511);
while (a && a != -1) a = read(fd, buf, 511);
if (a == -1)
{
perror ("read");
exit(1);
}
else printf ("EOF\n");
exit(0);
}
Why isn't there any error Eintr ?