1.\" $NetBSD: raise_default_signal.3,v 1.1 2007/09/25 01:13:56 lukem Exp $ 2.\" 3.\" Copyright (c) 2007 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Luke Mewburn. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd September 25, 2007 38.Dt RAISE_DEFAULT_SIGNAL 3 39.Os 40.Sh NAME 41.Nm raise_default_signal 42.Nd raise the default signal handler 43.Sh LIBRARY 44.Lb libutil 45.Sh SYNOPSIS 46.In util.h 47.Ft int 48.Fo raise_default_signal 49.Fa "int sig" 50.Fc 51.Sh DESCRIPTION 52The 53.Fn raise_default_signal 54function raises the default signal handler for the signal 55.Fa sig . 56This function may be used by a user-defined signal handler router 57to ensure that a parent process receives the correct notification 58of a process termination by a signal. 59This can be used to avoid a common programming mistake 60when terminating a process from a custom 61.Dv SIGINT 62or 63.Dv SIGQUIT 64signal handler. 65.Pp 66The operations performed are: 67.Bl -enum -offset indent 68.It 69Block all signals, using 70.Xr sigprocmask 3 . 71.It 72Set the signal handler for signal 73.Fa sig 74to the default signal handler 75.Dv ( SIG_DFL ) . 76.It 77.Xr raise 3 78signal 79.Fa sig . 80.It 81Unblock signal 82.Fa sig 83to deliver it. 84.It 85Restore the original signal mask and handler, 86even if there was a failure. 87.El 88.Pp 89See 90.Xr signal 7 91for a table of signals and default actions. 92.Pp 93The 94.Fn raise_default_signal 95function should be async-signal-safe. 96.Sh RETURN VALUES 97Upon successful completion, a value of 0 is returned. 98Otherwise, a value of \-1 is returned and the global variable 99.Va errno 100is set to indicate the error. 101.Sh ERRORS 102The 103.Fn raise_default_signal 104function may fail and set 105.Va errno 106for any of the errors specified for the functions 107.Xr sigemptyset 3 , 108.Xr sigfillset 3 , 109.Xr sigaddset 3 , 110.Xr sigprocmask 2 , 111.Xr sigaction 2 , 112or 113.Xr raise 3 . 114.Sh SEE ALSO 115.Xr sigaction 2 , 116.Xr sigprocmask 2 , 117.Xr raise 3 , 118.Xr signal 7 119.Sh HISTORY 120The 121.Fn raise_default_signal 122function first appeared in 123.Nx 5.0 . 124