Re: [PATCH] making dump EINTR resistant

Bruce Evans <[email protected]>
Newsgroups gmane.os.freebsd.devel.audit
Message-ID <[email protected]>
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 [email protected]
with "unsubscribe freebsd-audit" in the body of the message
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.