1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2015 Joyent, Inc.
13.\"
14.Dd November 27, 2023
15.Dt PR_CREAT 3PROC
16.Os
17.Sh NAME
18.Nm pr_exit
19.Nd inject exit system call into victim process
20.Sh LIBRARY
21.Lb libproc
22.Sh SYNOPSIS
23.In libproc.h
24.Ft int
25.Fo pr_exit
26.Fa "struct ps_prochandle *P"
27.Fa "int status"
28.Fc
29.Sh DESCRIPTION
30The
31.Fn pr_exit
32function injects the
33.Xr exit 2
34system call into the target process
35.Fa P
36by means of the agent LWP.
37If the process handle
38.Fa P
39is
40.Dv NULL
41then this is equivalent to calling
42.Xr exit 2
43on the currently running process.
44.Pp
45The argument
46.Fa status
47has the same meaning as in
48.Xr exit 2 .
49See
50.Xr exit 2
51for the full description and purpose of the
52.Sy exit
53system call and its arguments.
54.Pp
55The
56.Fn pr_exit
57function only works on active processes.
58Process handles that correspond to core files, zombie processes, or ELF objects
59do not support system call injection.
60.Sh RETURN VALUES
61Upon successful completion, the
62.Fn pr_exit
63function's return value is that described in
64.Xr exit 2 .
65Otherwise,
66.Sy -1
67is returned and
68.Sy errno
69is set to
70.Er ENOSYS
71to indicate that the system call could not be injected.
72.Pp
73If the
74.Fn pr_exit
75function is called with the value of
76.Fa P
77set to
78.Dv NULL ,
79then the function will not return.
80.Sh ERRORS
81For the full list of errors see the
82.Sy ERRORS
83section in
84.Xr exit 2 .
85.Pp
86The
87.Fn pr_exit
88function will fail if:
89.Bl -tag -width Er
90.It Er ENOSYS
91An error occurred while trying to invoke the agent LWP and inject a
92system call in the process handle
93.Fa P
94or the process handle
95.Fa P
96does not support system call injection.
97.El
98.Sh INTERFACE STABILITY
99.Sy Uncommitted
100.Sh MT-LEVEL
101See
102.Sy LOCKING
103in
104.Xr libproc 3LIB .
105.Sh SEE ALSO
106.Xr exit 2 ,
107.Xr libproc 3LIB ,
108.Xr proc 5
109