xref: /dflybsd-src/lib/libc/sys/extexit.2 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino.\" Copyright (c) 2007 The DragonFly Project.  All rights reserved.
286d7f5d3SJohn Marino.\"
386d7f5d3SJohn Marino.\" This code is derived from software contributed to The DragonFly Project
486d7f5d3SJohn Marino.\" by Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
586d7f5d3SJohn Marino.\"
686d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without
786d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions
886d7f5d3SJohn Marino.\" are met:
986d7f5d3SJohn Marino.\"
1086d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
1186d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
1286d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
1386d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer in
1486d7f5d3SJohn Marino.\"    the documentation and/or other materials provided with the
1586d7f5d3SJohn Marino.\"    distribution.
1686d7f5d3SJohn Marino.\" 3. Neither the name of The DragonFly Project nor the names of its
1786d7f5d3SJohn Marino.\"    contributors may be used to endorse or promote products derived
1886d7f5d3SJohn Marino.\"    from this software without specific, prior written permission.
1986d7f5d3SJohn Marino.\"
2086d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2186d7f5d3SJohn Marino.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2286d7f5d3SJohn Marino.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2386d7f5d3SJohn Marino.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
2486d7f5d3SJohn Marino.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2586d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
2686d7f5d3SJohn Marino.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2786d7f5d3SJohn Marino.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2886d7f5d3SJohn Marino.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2986d7f5d3SJohn Marino.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3086d7f5d3SJohn Marino.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3186d7f5d3SJohn Marino.\" SUCH DAMAGE.
3286d7f5d3SJohn Marino.\"
3386d7f5d3SJohn Marino.\" $DragonFly: src/lib/libc/sys/extexit.2,v 1.5 2008/05/02 02:05:04 swildner Exp $
3486d7f5d3SJohn Marino.\"
3586d7f5d3SJohn Marino.Dd February 24, 2007
3686d7f5d3SJohn Marino.Dt EXTEXIT 2
3786d7f5d3SJohn Marino.Os
3886d7f5d3SJohn Marino.Sh NAME
3986d7f5d3SJohn Marino.Nm extexit
4086d7f5d3SJohn Marino.Nd terminate the calling lwp or process and perform action
4186d7f5d3SJohn Marino.Sh LIBRARY
4286d7f5d3SJohn Marino.Lb libc
4386d7f5d3SJohn Marino.Sh SYNOPSIS
4486d7f5d3SJohn Marino.In unistd.h
4586d7f5d3SJohn Marino.Ft void
4686d7f5d3SJohn Marino.Fn extexit "int how" "int status" "void *addr"
4786d7f5d3SJohn Marino.Sh DESCRIPTION
4886d7f5d3SJohn MarinoThe
4986d7f5d3SJohn Marino.Fn extexit
5086d7f5d3SJohn Marinofunction terminates a lwp or process and performs an action.
5186d7f5d3SJohn MarinoThis is a low level service routine not intended to be used
5286d7f5d3SJohn Marinofrom common user code.
5386d7f5d3SJohn Marino.Pp
5486d7f5d3SJohn MarinoThe
5586d7f5d3SJohn Marino.Fn extexit
5686d7f5d3SJohn Marinofunction can be used to either exit a lwp or a complete process.
5786d7f5d3SJohn MarinoThis is done by specifying either
5886d7f5d3SJohn Marino.Dv EXTEXIT_PROC
5986d7f5d3SJohn Marinoor
6086d7f5d3SJohn Marino.Dv EXTEXIT_LWP
6186d7f5d3SJohn Marinoin
6286d7f5d3SJohn Marino.Fa how .
6386d7f5d3SJohn MarinoIf exiting the process or if exiting the last lwp of a process,
6486d7f5d3SJohn Marino.Fn extexit
6586d7f5d3SJohn Marinobehaves like
6686d7f5d3SJohn Marino.Xr _exit 2
6786d7f5d3SJohn Marinocalled with the
6886d7f5d3SJohn Marino.Fa status
6986d7f5d3SJohn Marinoargument.
7086d7f5d3SJohn Marino.Pp
7186d7f5d3SJohn MarinoAdditionally,
7286d7f5d3SJohn Marino.Fn extexit
7386d7f5d3SJohn Marinocan be used to perform certain actions when exiting.
7486d7f5d3SJohn MarinoThe following actions can be specified by
7586d7f5d3SJohn Marino.Em or Ns 'ing
7686d7f5d3SJohn Marinothese values in the
7786d7f5d3SJohn Marino.Fa how
7886d7f5d3SJohn Marinoargument:
7986d7f5d3SJohn Marino.Bl -tag -width ".Dv EXTEXIT_SIMPLE"
8086d7f5d3SJohn Marino.It Dv EXTEXIT_SETINT
8186d7f5d3SJohn MarinoSet the integer variable pointer to by
8286d7f5d3SJohn Marino.Fa addr
8386d7f5d3SJohn Marinoto the value of
8486d7f5d3SJohn Marino.Fa status .
8586d7f5d3SJohn MarinoThis is intended to enable other threads or processes to
8686d7f5d3SJohn Marinodetect the termination of the calling lwp or process.
8786d7f5d3SJohn Marino.El
8886d7f5d3SJohn Marino.Sh RETURN VALUES
8986d7f5d3SJohn MarinoThe
9086d7f5d3SJohn Marino.Fn extexit
9186d7f5d3SJohn Marinofunction will only return if it was invoked
9286d7f5d3SJohn Marinowith invalid arguments.  In this case,
9386d7f5d3SJohn Marino.Va errno
9486d7f5d3SJohn Marinowill be set to
9586d7f5d3SJohn Marino.Er EINVAL .
9686d7f5d3SJohn MarinoIn the case of a successful invocation,
9786d7f5d3SJohn Marino.Fn extexit
9886d7f5d3SJohn Marinowill not return.
9986d7f5d3SJohn Marino.Pp
10086d7f5d3SJohn MarinoIn case of an error, the action specified in
10186d7f5d3SJohn Marino.Fa how
10286d7f5d3SJohn Marinowill not be performed.
10386d7f5d3SJohn MarinoIf an error occurs while performing an action, the results are
10486d7f5d3SJohn Marinoundefined.
10586d7f5d3SJohn MarinoHowever,
10686d7f5d3SJohn Marino.Fn extexit
10786d7f5d3SJohn Marinowill try hard to avoid such a situation.
10886d7f5d3SJohn MarinoIn any case, if an error occurs while performing an action,
10986d7f5d3SJohn Marino.Fn extexit
11086d7f5d3SJohn Marinowill return.
11186d7f5d3SJohn Marino.Sh SEE ALSO
11286d7f5d3SJohn Marino.Xr _exit 2 ,
11386d7f5d3SJohn Marino.Xr wait 2 ,
11486d7f5d3SJohn Marino.Xr exit 3
11586d7f5d3SJohn Marino.Sh HISTORY
11686d7f5d3SJohn MarinoThe
11786d7f5d3SJohn Marino.Fn extexit
11886d7f5d3SJohn Marinofunction first appeared in
11986d7f5d3SJohn Marino.Dx 1.9 .
120