Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jun 2002 06:51:27 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Alexander Leidinger <Alexander@Leidinger.net>
Cc:        Todd.Miller@courtesan.com, <drosih@rpi.edu>, <audit@FreeBSD.ORG>
Subject:   Re: [PATCH] making dump EINTR resistant
Message-ID:  <20020606064418.N8685-100000@gamplex.bde.org>
In-Reply-To: <200206050838.g558c0PP000854@Magelan.Leidinger.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 5 Jun 2002, Alexander Leidinger wrote:

> On  5 Jun, Bruce Evans wrote:
>
> >> It would probably be better to just make the code in question to
> >> just use sigaction() if you are concerned about portability.  That
> >> way you get consistent handling of syscall restarts.
> >
> > I agree, but not that SA_RESTART wasn't portable until tomorrow (sic),
> > since it is in POSIX.1-2001 but not in older POSIXes (.1-1996 at least).
>
> Stevens uses this as a portable example for a signal() with restartable
> syscalls:
>
> ---snip---
> #include <signal.h>
>
> typedef void Sigfunc(int);
>
> Sigfunc *
> signal(int signo, Sigfunc *func)
> {
> 	struct sigaction	act, oact;
>
> 	act.sa_handler = func;
> 	sigemptyset(&act.sa_mask);
> 	act.sa_flags = 0;
> 	if (signo == SIGALRM) {
> #ifdef	SA_INTERRUPT
> 		act.sa_flags |= SA_INTERRUPT;	/* SunOS */
> #endif
> 	} else {
> #ifdef	SA_RESTART
> 		act.sa_flags |= SA_RESTART;	/* SVR4, 4.3+BSD */
> #endif
> 	}
> 	if (sigaction(signo, &act, &oact) < 0)
> 		return(SIG_ERR);
> 	return (oact.sa_handler);
> }

It's not very portable since it doesn't give restartable syscalls on
systems that don't have SA_INTERRUPT or SA_RESTART.  The rest of the
application would have to deal with this possibilty, and once it does
that it can just slightly more easily deal with non-restartable syscalls
in all cases.

> He doesn't want restartable syscalls for SIGALRM to allow to set a time
> out for I/O operations.

This is probably necessary for programs that need i/o's to time out or
be terminated by a keyboard signal, but it requires the whole program
to be concerned about i/o's failing with EINTR -- it is only a small
simplification for only one type of signal to not restart syscalls,
since that signal may occur.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020606064418.N8685-100000>