| 1 |
.TH "CAPNG_SETPID" "3" "March 2026" "Red Hat" "Libcap-ng API" |
| 2 |
.SH NAME |
| 3 |
capng_setpid \- set working pid |
| 4 |
.SH "SYNOPSIS" |
| 5 |
.B #include <cap-ng.h> |
| 6 |
.sp |
| 7 |
void capng_setpid(int pid); |
| 8 |
|
| 9 |
.SH "DESCRIPTION" |
| 10 |
|
| 11 |
capng_setpid sets the working pid for capabilities operations. This is useful if you want to get the capabilities of a different process. |
| 12 |
|
| 13 |
.SH NOTES |
| 14 |
|
| 15 |
If your process calls |
| 16 |
.B fork |
| 17 |
, then the child process will still have the pid of the parent process stored in libcap-ng's internal data. It is disallowed to do any kind of setcap operations because you would be crossing process boundaries. To correct this, if your program links against pthreads, then libcap-ng will use the |
| 18 |
.B pthread_atfork |
| 19 |
function (as a weak symbol) to reset the pid information to the new process automatically. You are not required to link against pthreads. You can call |
| 20 |
.B capng_setpid |
| 21 |
and adjust the stored pid manually. |
| 22 |
|
| 23 |
.SH "RETURN VALUE" |
| 24 |
|
| 25 |
None. |
| 26 |
|
| 27 |
.SH "SEE ALSO" |
| 28 |
|
| 29 |
.BR capng_get_caps_process (3), |
| 30 |
.BR capabilities (7) |
| 31 |
|
| 32 |
.SH AUTHOR |
| 33 |
Steve Grubb |