Subject: Re: save/restore fpu for the signal handler call
To: Pavel Cahyna <pavel.cahyna@st.mff.cuni.cz>
From: Rui Paulo <rpaulo@fnop.net>
List: port-i386
Date: 11/30/2005 20:54:55
--iFRdW5/EC4oqxDHL
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2005.11.30 21:36:06 +0100, Pavel Cahyna wrote:
| On Wed, Nov 30, 2005 at 09:16:53PM +0100, Jaromir Dolecek wrote:
| > On Wed, Nov 30, 2005 at 02:32:12PM -0500, der Mouse wrote:
| > > No - only that FP arithmetic on values shared with non-signal use is
| > > unpredicable.  But something like
| > >=20
| > > 	printf("%.2f%% done\n",done*100.0/total);
| > >=20
| > > inside a SIGINFO handler is totally reasonable.
| >=20
| > Except that printf() isn't :) You cannot safely access
| > stdio within signal handler.
|=20
| Why not?

signal(7):

     A function that is async-signal-safe is either reentrant or non-inter-
     ruptible by signals.  This means that they can be used in signal handl=
ers
     and in the child of threaded programs after doing fork(2).

     The following functions are async-signal-safe.  Any function not listed
     below is unsafe to use in signal handlers.

     _Exit(2), _exit(2), abort(3), accept(2), access(2), alarm(3), bind(2),
     cfgetispeed(3), cfgetospeed(3), cfsetispeed(3), cfsetospeed(3), chdir(=
2),
     chmod(2), chown(2), clock_gettime(2), close(2), connect(2), creat(3),
     dup(2), dup2(2), execle(3), execve(3), fchmod(2), fchown(2), fcntl(2),
     fdatasync(2), fork(2), fpathconf(2), fstat(2), fsync(2), ftruncate(2),
     getegid(2), geteuid(2), getgid(2), getgroups(2), getpeername(2),
     getpgrp(2), getpid(2), getppid(2), getsockname(2), getsockopt(2),
     getuid(2), kill(2), link(2), listen(2), lseek(2), lstat(2), mkdir(2),
     mkfifo(2), open(2), pathconf(2), pause(3), pipe(2), poll(2), raise(3),
     read(2), readlink(2), recv(2), recvfrom(2), recvmsg(2), rename(2),
     rmdir(2,) select(2), sem_post(3), send(2), sendmsg(2), sendto(2),
     setgid(2), setpgid(2), setsid(2), setsockopt(2), setuid(2), shutdown(2=
),
     sigaction(2), sigaddset(3), sigdelset(3), sigemptyset(3), sigfillset(3=
),
     sigismember(3), sleep(3), signal(3), sigpause(3), sigpending(2),
     sigprocmask(2), sigset(3), sigsuspend(2), sockatmark(3), socket(2),
     socketpair(2), stat(2), symlink(2), sysconf(3), tcdrain(3), tcflow(3),
     tcflush(3), tcgetattr(3), tcgetpgrp(3), tcsendbreak(3), tcsetattr(3),
     tcsetpgrp(3), time(3), timer_getoverrun(2), timer_gettime(2),
     timer_settime(2), times(3), umask(2), uname(3), unlink(2), utime(3),
     wait(2), waitpid(2), write(2).

		-- Rui Paulo

--iFRdW5/EC4oqxDHL
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)

iD8DBQFDjhGfZPqyxs9FH4QRAiVBAKCQu8IXeB2cgKbWHZH8JOROpY4LgACaAj3f
vNUykVcDKcc3LWPeUDf90kM=
=uTuS
-----END PGP SIGNATURE-----

--iFRdW5/EC4oqxDHL--