1.\" $NetBSD: raise_default_signal.3,v 1.3 2011/03/27 12:53:16 njoly 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.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd September 25, 2007 31.Dt RAISE_DEFAULT_SIGNAL 3 32.Os 33.Sh NAME 34.Nm raise_default_signal 35.Nd raise the default signal handler 36.Sh LIBRARY 37.Lb libutil 38.Sh SYNOPSIS 39.In util.h 40.Ft int 41.Fo raise_default_signal 42.Fa "int sig" 43.Fc 44.Sh DESCRIPTION 45The 46.Fn raise_default_signal 47function raises the default signal handler for the signal 48.Fa sig . 49This function may be used by a user-defined signal handler router 50to ensure that a parent process receives the correct notification 51of a process termination by a signal. 52This can be used to avoid a common programming mistake 53when terminating a process from a custom 54.Dv SIGINT 55or 56.Dv SIGQUIT 57signal handler. 58.Pp 59The operations performed are: 60.Bl -enum -offset indent 61.It 62Block all signals, using 63.Xr sigprocmask 2 . 64.It 65Set the signal handler for signal 66.Fa sig 67to the default signal handler 68.Dv ( SIG_DFL ) . 69.It 70.Xr raise 3 71signal 72.Fa sig . 73.It 74Unblock signal 75.Fa sig 76to deliver it. 77.It 78Restore the original signal mask and handler, 79even if there was a failure. 80.El 81.Pp 82See 83.Xr signal 7 84for a table of signals and default actions. 85.Pp 86The 87.Fn raise_default_signal 88function should be async-signal-safe. 89.Sh RETURN VALUES 90Upon successful completion, a value of 0 is returned. 91Otherwise, a value of \-1 is returned and the global variable 92.Va errno 93is set to indicate the error. 94.Sh ERRORS 95The 96.Fn raise_default_signal 97function may fail and set 98.Va errno 99for any of the errors specified for the functions 100.Xr sigemptyset 3 , 101.Xr sigfillset 3 , 102.Xr sigaddset 3 , 103.Xr sigprocmask 2 , 104.Xr sigaction 2 , 105or 106.Xr raise 3 . 107.Sh SEE ALSO 108.Xr sigaction 2 , 109.Xr sigprocmask 2 , 110.Xr raise 3 , 111.Xr signal 7 112.Sh HISTORY 113The 114.Fn raise_default_signal 115function first appeared in 116.Nx 5.0 . 117