Incorect signal handling ?

From: Daniel Podlejski (underley@underley.eu.org)
Date: Thu Apr 12 2001 - 15:31:28 EST


Hi,

there is litlle programm:

#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);
}

I open /tmp/nic and run compiled program.
There should be error EINTR in read, but isn't.
Why ?

-- 
Daniel Podlejski <underley@underley.eu.org>
   ... Here await the birth of the son
   The seventh, the heavenly, the chosen one ...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 15 2001 - 21:00:19 EST