From owner-svn-src-all@FreeBSD.ORG Fri May 31 21:25:51 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A100FC4E; Fri, 31 May 2013 21:25:51 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 91D5BDB0; Fri, 31 May 2013 21:25:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4VLPpng071506; Fri, 31 May 2013 21:25:51 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4VLPppF071505; Fri, 31 May 2013 21:25:51 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201305312125.r4VLPppF071505@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 31 May 2013 21:25:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251196 - head/lib/libc/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 May 2013 21:25:51 -0000 Author: jilles Date: Fri May 31 21:25:51 2013 New Revision: 251196 URL: http://svnweb.freebsd.org/changeset/base/251196 Log: sigaction(2): Extend description of async-signal safe functions: * Improve description when unsafe functions are unsafe. * Add various safe functions from POSIX.1-2008 and Austin Group issue #692. Modified: head/lib/libc/sys/sigaction.2 Modified: head/lib/libc/sys/sigaction.2 ============================================================================== --- head/lib/libc/sys/sigaction.2 Fri May 31 21:05:07 2013 (r251195) +++ head/lib/libc/sys/sigaction.2 Fri May 31 21:25:51 2013 (r251196) @@ -28,7 +28,7 @@ .\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94 .\" $FreeBSD$ .\" -.Dd September 27, 2012 +.Dd May 31, 2013 .Dt SIGACTION 2 .Os .Sh NAME @@ -346,13 +346,19 @@ Any attempt to do so will be silently ig The following functions are either reentrant or not interruptible by signals and are async-signal safe. Therefore applications may -invoke them, without restriction, from signal-catching functions: +invoke them, without restriction, from signal-catching functions +or from a child process after calling +.Xr fork 2 +in a multi-threaded process: .Pp Base Interfaces: .Pp +.Fn _Exit , .Fn _exit , +.Fn accept , .Fn access , .Fn alarm , +.Fn bind , .Fn cfgetispeed , .Fn cfgetospeed , .Fn cfsetispeed , @@ -361,41 +367,65 @@ Base Interfaces: .Fn chmod , .Fn chown , .Fn close , +.Fn connect , .Fn creat , .Fn dup , .Fn dup2 , +.Fn execl , .Fn execle , +.Fn execv , .Fn execve , +.Fn fchdir , +.Fn fchmod , +.Fn fchown , .Fn fcntl , .Fn fork , -.Fn fpathconf , .Fn fstat , .Fn fsync , +.Fn ftruncate , .Fn getegid , .Fn geteuid , .Fn getgid , .Fn getgroups , +.Fn getpeername , .Fn getpgrp , .Fn getpid , .Fn getppid , +.Fn getsockname , +.Fn getsockopt , .Fn getuid , .Fn kill , .Fn link , +.Fn listen , .Fn lseek , +.Fn lstat , .Fn mkdir , .Fn mkfifo , +.Fn mknod , .Fn open , -.Fn pathconf , .Fn pause , .Fn pipe , +.Fn poll , +.Fn pselect , +.Fn pthread_sigmask , .Fn raise , .Fn read , +.Fn readlink , +.Fn recv , +.Fn recvfrom , +.Fn recvmsg , .Fn rename , .Fn rmdir , +.Fn select , +.Fn send , +.Fn sendmsg , +.Fn sendto , .Fn setgid , .Fn setpgid , .Fn setsid , +.Fn setsockopt , .Fn setuid , +.Fn shutdown , .Fn sigaction , .Fn sigaddset , .Fn sigdelset , @@ -407,8 +437,11 @@ Base Interfaces: .Fn sigprocmask , .Fn sigsuspend , .Fn sleep , +.Fn sockatmark , +.Fn socket , +.Fn socketpair , .Fn stat , -.Fn sysconf , +.Fn symlink , .Fn tcdrain , .Fn tcflow , .Fn tcflush , @@ -427,11 +460,16 @@ Base Interfaces: .Fn waitpid , .Fn write . .Pp +X/Open Systems Interfaces: +.Pp +.Fn sigpause , +.Fn sigset , +.Fn utimes . +.Pp Realtime Interfaces: .Pp .Fn aio_error , .Fn clock_gettime , -.Fn sigpause , .Fn timer_getoverrun , .Fn aio_return , .Fn fdatasync , @@ -439,27 +477,84 @@ Realtime Interfaces: .Fn timer_gettime , .Fn aio_suspend , .Fn sem_post , -.Fn sigset , .Fn timer_settime . .Pp -.Tn ANSI C -Interfaces: +Base Interfaces not specified as async-signal safe by +.Tn POSIX : .Pp -.Fn strcpy , +.Fn fpathconf , +.Fn pathconf , +.Fn sysconf . +.Pp +Base Interfaces not specified as async-signal safe by +.Tn POSIX , +but planned to be: +.Pp +.Fn ffs , +.Fn htonl , +.Fn htons , +.Fn memccpy , +.Fn memchr , +.Fn memcmp , +.Fn memcpy , +.Fn memmove , +.Fn memset , +.Fn ntohl , +.Fn ntohs , +.Fn stpcpy , +.Fn stpncpy , .Fn strcat , -.Fn strncpy , +.Fn strchr , +.Fn strcmp , +.Fn strcpy , +.Fn strcspn , +.Fn strlen , .Fn strncat , -and perhaps some others. +.Fn strncmp , +.Fn strncpy , +.Fn strnlen , +.Fn strpbrk , +.Fn strrchr , +.Fn strspn , +.Fn strstr , +.Fn strtok_r , +.Fn wcpcpy , +.Fn wcpncpy , +.Fn wcscat , +.Fn wcschr , +.Fn wcscmp , +.Fn wcscpy , +.Fn wcscspn , +.Fn wcslen , +.Fn wcsncat , +.Fn wcsncmp , +.Fn wcsncpy , +.Fn wcsnlen , +.Fn wcspbrk , +.Fn wcsrchr , +.Fn wcsspn , +.Fn wcsstr , +.Fn wcstok , +.Fn wmemchr , +.Fn wmemcmp , +.Fn wmemcpy , +.Fn wmemmove , +.Fn wmemset . .Pp Extension Interfaces: .Pp .Fn strlcpy , .Fn strlcat . .Pp +In addition, reading or writing +.Va errno +is async-signal safe. +.Pp All functions not in the above lists are considered to be unsafe with respect to signals. That is to say, the behaviour of such -functions when called from a signal handler is undefined. +functions is undefined when they are called from a signal handler +that interrupted an unsafe function. In general though, signal handlers should do little more than set a flag; most other actions are not safe. .Pp