Re: SIGCONT misbehaviour in Linux

Richard B. Johnson (root@chaos.analogic.com)
Wed, 8 Dec 1999 17:32:32 -0500 (EST)


> By author: Simon Kirby <sim@stormix.com>
> In newsgroup: linux.dev.kernel
>
> and the process running sleep 1000 immediatly returns on Linux.
> I tested it on other systems and it works correctly (the sleep
> continue).

This shows the operation of the SA_RESTART flag. If you don't want
the system call to return to the caller with -1 and EINTR, you
have to use this.

#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <string.h>

void foo(int unused) { puts("\7Alarm"); }

main(int x)
{
struct sigaction sa;
char buf[1];
int i;
memset(&sa, 0x00, sizeof(sa));
if(x > 1)
sa.sa_flags = SA_RESTART;
sa.sa_handler = foo;
sigaction(SIGALRM, &sa, NULL);
alarm(1);
i = read(0, buf, 1);
printf("%d, %s\n", i, strerror(errno));
}

Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : The end of the world as we know it requires a new calendar.
Seconds : 2010448 (until Y2K)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/