xref: /illumos-gate/usr/src/man/man3proc/pr_fcntl.3proc (revision 08855964b9970604433f7b19dcd71cf5af5e5f14)
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 July 30, 2024
15.Dt PR_FCNTL 3PROC
16.Os
17.Sh NAME
18.Nm pr_fcntl
19.Nd inject fcntl system call into victim process
20.Sh LIBRARY
21.Lb libproc
22.Sh SYNOPSIS
23.In libproc.h
24.Ft int
25.Fo pr_fcntl
26.Fa "struct ps_prochandle *P"
27.Fa "int fd"
28.Fa "int cmd"
29.Fa "void *argp0"
30.Fa "void *argp1"
31.Fc
32.Sh DESCRIPTION
33The
34.Fn pr_fcntl
35function injects the
36.Xr fcntl 2
37system call into the target process
38.Fa P
39by means of the agent LWP.
40If the process handle
41.Fa P
42is
43.Dv NULL
44then this is equivalent to calling
45.Xr fcntl 2
46on the currently running process.
47.Pp
48The arguments
49.Fa fd
50and
51.Fa cmd
52have the same meaning as in
53.Xr fcntl 2 .
54The value of
55.Fa cmd
56determines how many arguments are passed.
57A command that takes no arguments, like
58.Dv F_GETFD ,
59should pass both
60.Fa argp0
61and
62.Fa argp1
63as
64.Dv NULL .
65A command that takes integer arguments, like
66.Dv F_SETFL
67or
68.Dv F_DUP3FD ,
69should cast the integer arguments to a
70.Fa "void *"
71and pass unused arguments as
72.Dv NULL .
73See
74.Xr fcntl 2
75for the full description and purpose of the
76system call and its arguments.
77.Pp
78The
79.Fn pr_fcntl
80function only works on active processes.
81Process handles that correspond to core files, zombie processes, or ELF objects
82do not support system call injection.
83.Sh RETURN VALUES
84Upon successful completion, the
85.Fn pr_fcntl
86function's return value is that described in
87.Xr fcntl 2 .
88Otherwise,
89.Sy -1
90is returned and
91.Sy errno
92is set to
93.Er ENOSYS
94to indicate that the system call could not be injected.
95.Sh ERRORS
96For the full list of errors see the
97.Sy ERRORS
98section in
99.Xr fcntl 2 .
100.Pp
101The
102.Fn pr_fcntl
103function will fail if:
104.Bl -tag -width Er
105.It Er ENOSYS
106An error occurred while trying to invoke the agent LWP and inject a
107system call in the process handle
108.Fa P
109or the process handle
110.Fa P
111does not support system call injection.
112.El
113.Sh INTERFACE STABILITY
114.Sy Uncommitted
115.Sh MT-LEVEL
116See
117.Sy LOCKING
118in
119.Xr libproc 3LIB .
120.Sh SEE ALSO
121.Xr fcntl 2 ,
122.Xr libproc 3LIB ,
123.Xr proc 5
124