lkml.org 
[lkml]   [1996]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectPOSIX compatibility?
    From
    Date

    Hi,

    could somebody enlighten me? According to POSIX.1 the following
    program should exit with status 0:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #include <errno.h>
    #include <signal.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <stdio.h>

    int was_sig = -1;

    void
    sighand (int sig)
    {
    was_sig = sig;
    }

    int
    main()
    {
    struct sigaction sa;
    int fildes[2];
    FILE *fp;
    int ch, result;

    sa.sa_handler = sighand;
    sigemptyset (&sa.sa_mask);
    sa.sa_flags = 0;
    sigaction (SIGALRM, &sa, NULL);

    pipe(fildes);
    fp = fdopen (fildes[0], "r");

    alarm(2);

    ch = fgetc (fp);

    result = ch == EOF && errno == EINTR;
    alarm(0);

    return result;
    }
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    But when I run this program I get (using strace):

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [...]
    personality(PER_LINUX) = 0
    sigaction(SIGALRM, {0x8048970, [], 0}, NULL) = 0
    pipe([3, 4]) = 0
    fcntl(3, F_GETFL) = 0 (flags O_RDONLY)
    brk(0) = 0x804ac7c
    brk(0x804acfc) = 0x804acfc
    brk(0x804b000) = 0x804b000
    fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
    brk(0x804d000) = 0x804d000
    lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
    alarm(2) = 0
    read(3, 0x804acf8, 4096) = ? ERESTARTSYS (To be restarted)
    --- SIGALRM (Alarm clock) ---
    sigreturn() = ? (mask now [])
    read(3, <unfinished ...>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I used C-c to teerminate the process. Why does read() does not return
    with errno set to EINTR?

    -- Uli
    ---------------. drepper@cygnus.com ,-. Rubensstrasse 5
    Ulrich Drepper \ ,-------------------' \ 76149 Karlsruhe/Germany
    Cygnus Solutions `--' drepper@gnu.ai.mit.edu `------------------------

    \
     
     \ /
      Last update: 2005-03-22 13:37    [W:0.021 / U:4.128 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site