diff --git a/lib/libc/gen/ftok.3 b/lib/libc/gen/ftok.3 index b819dbd185d4..88c366a7dcf3 100644 --- a/lib/libc/gen/ftok.3 +++ b/lib/libc/gen/ftok.3 @@ -1,83 +1,82 @@ .\" Copyright (c) 1994 SigmaSoft, Th. Lockert .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. The name of the author may not be used to endorse or promote products .\" derived from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, .\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; .\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd July 9, 2009 +.Dd November 28, 2022 .Dt FTOK 3 .Os .Sh NAME .Nm ftok .Nd create IPC identifier from path name .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In sys/ipc.h .Ft key_t .Fn ftok "const char *path" "int id" .Sh DESCRIPTION The .Fn ftok function attempts to create a unique key suitable for use with the .Xr msgget 2 , .Xr semget 2 and .Xr shmget 2 functions given the .Fa path of an existing file and a user-selectable .Fa id . .Pp The specified .Fa path must specify an existing file that is accessible to the calling process or the call will fail. Also, note that links to files will return the same key, given the same .Fa id . .Sh RETURN VALUES The .Fn ftok function will return -1 if .Fa path does not exist or if it cannot be accessed by the calling process. .Sh SEE ALSO .Xr msgget 2 , .Xr semget 2 , .Xr shmget 2 .Sh HISTORY The .Fn ftok function originates with System V and is typically used by programs that use the System V IPC routines. .Sh AUTHORS .An Thorsten Lockert Aq Mt tholo@sigmasoft.com .Sh BUGS The returned key is computed based on the device minor number and inode of the specified .Fa path in combination with the lower 8 bits of the given .Fa id . Thus it is quite possible for the routine to return duplicate keys. diff --git a/lib/libc/gen/getpeereid.3 b/lib/libc/gen/getpeereid.3 index 3c99eeda37f0..ec9b60b461db 100644 --- a/lib/libc/gen/getpeereid.3 +++ b/lib/libc/gen/getpeereid.3 @@ -1,137 +1,136 @@ .\" .\" Copyright (c) 2001 Dima Dorfman. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd February 3, 2017 +.Dd November 28, 2022 .Dt GETPEEREID 3 .Os .Sh NAME .Nm getpeereid .Nd get the effective credentials of a UNIX-domain peer .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In unistd.h .Ft int .Fn getpeereid "int s" "uid_t *euid" "gid_t *egid" .Sh DESCRIPTION The .Fn getpeereid function returns the effective user and group IDs of the peer connected to a .Ux Ns -domain socket. The argument .Fa s must be a .Ux Ns -domain socket .Pq Xr unix 4 of type .Dv SOCK_STREAM on which either .Xr connect 2 or .Xr listen 2 has been called. The effective user ID is placed in .Fa euid , and the effective group ID in .Fa egid . .Pp The credentials returned to the .Xr listen 2 caller are those of its peer at the time it called .Xr connect 2 ; the credentials returned to the .Xr connect 2 caller are those of its peer at the time it called .Xr listen 2 . This mechanism is reliable; there is no way for either side to influence the credentials returned to its peer except by calling the appropriate system call (i.e., either .Xr connect 2 or .Xr listen 2 ) under different effective credentials. .Pp One common use of this routine is for a .Ux Ns -domain server to verify the credentials of its client. Likewise, the client can verify the credentials of the server. .Sh IMPLEMENTATION NOTES On .Fx , .Fn getpeereid is implemented in terms of the .Dv LOCAL_PEERCRED .Xr unix 4 socket option. .Sh RETURN VALUES .Rv -std getpeereid .Sh ERRORS The .Fn getpeereid function fails if: .Bl -tag -width Er .It Bq Er EBADF The argument .Fa s is not a valid descriptor. .It Bq Er ENOTSOCK The argument .Fa s is a file, not a socket. .It Bq Er ENOTCONN The argument .Fa s does not refer to a socket on which .Xr connect 2 or .Xr listen 2 have been called. .It Bq Er EINVAL The argument .Fa s does not refer to a socket of type .Dv SOCK_STREAM , or the kernel returned invalid data. .El .Sh SEE ALSO .Xr connect 2 , .Xr getpeername 2 , .Xr getsockname 2 , .Xr getsockopt 2 , .Xr listen 2 , .Xr unix 4 .Sh HISTORY The .Fn getpeereid function appeared in .Fx 4.6 . diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3 index d7043d814802..782c4f729ecd 100644 --- a/lib/libc/gen/getpwent.3 +++ b/lib/libc/gen/getpwent.3 @@ -1,315 +1,314 @@ .\" Copyright (c) 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" From: @(#)getpwent.3 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd April 16, 2003 +.Dd November 28, 2022 .Dt GETPWENT 3 .Os .Sh NAME .Nm getpwent , .Nm getpwent_r , .Nm getpwnam , .Nm getpwnam_r , .Nm getpwuid , .Nm getpwuid_r , .Nm setpassent , .Nm setpwent , .Nm endpwent .Nd password database operations .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In pwd.h .Ft struct passwd * .Fn getpwent void .Ft int .Fn getpwent_r "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result" .Ft struct passwd * .Fn getpwnam "const char *login" .Ft int .Fn getpwnam_r "const char *name" "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result" .Ft struct passwd * .Fn getpwuid "uid_t uid" .Ft int .Fn getpwuid_r "uid_t uid" "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result" .Ft int .Fn setpassent "int stayopen" .Ft void .Fn setpwent void .Ft void .Fn endpwent void .Sh DESCRIPTION These functions operate on the password database file which is described in .Xr passwd 5 . Each entry in the database is defined by the structure .Vt passwd found in the include file .In pwd.h : .Bd -literal -offset indent struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ uid_t pw_uid; /* user uid */ gid_t pw_gid; /* user gid */ time_t pw_change; /* password change time */ char *pw_class; /* user access class */ char *pw_gecos; /* Honeywell login info */ char *pw_dir; /* home directory */ char *pw_shell; /* default shell */ time_t pw_expire; /* account expiration */ int pw_fields; /* internal: fields filled in */ }; .Ed .Pp The functions .Fn getpwnam and .Fn getpwuid search the password database for the given login name or user uid, respectively, always returning the first one encountered. .Pp The .Fn getpwent function sequentially reads the password database and is intended for programs that wish to process the complete list of users. .Pp The functions .Fn getpwent_r , .Fn getpwnam_r , and .Fn getpwuid_r are thread-safe versions of .Fn getpwent , .Fn getpwnam , and .Fn getpwuid , respectively. The caller must provide storage for the results of the search in the .Fa pwd , .Fa buffer , .Fa bufsize , and .Fa result arguments. When these functions are successful, the .Fa pwd argument will be filled-in, and a pointer to that argument will be stored in .Fa result . If an entry is not found or an error occurs, .Fa result will be set to .Dv NULL . .Pp The .Fn setpassent function accomplishes two purposes. First, it causes .Fn getpwent to ``rewind'' to the beginning of the database. Additionally, if .Fa stayopen is non-zero, file descriptors are left open, significantly speeding up subsequent accesses for all of the routines. (This latter functionality is unnecessary for .Fn getpwent as it does not close its file descriptors by default.) .Pp It is dangerous for long-running programs to keep the file descriptors open as the database will become out of date if it is updated while the program is running. .Pp The .Fn setpwent function is identical to .Fn setpassent with an argument of zero. .Pp The .Fn endpwent function closes any open files. .Pp These routines have been written to ``shadow'' the password file, e.g.\& allow only certain programs to have access to the encrypted password. If the process which calls them has an effective uid of 0, the encrypted password will be returned, otherwise, the password field of the returned structure will point to the string .Ql * . .Sh RETURN VALUES The functions .Fn getpwent , .Fn getpwnam , and .Fn getpwuid return a valid pointer to a passwd structure on success or .Dv NULL if the entry is not found or if an error occurs. If an error does occur, .Va errno will be set. Note that programs must explicitly set .Va errno to zero before calling any of these functions if they need to distinguish between a non-existent entry and an error. The functions .Fn getpwent_r , .Fn getpwnam_r , and .Fn getpwuid_r return 0 if no error occurred, or an error number to indicate failure. It is not an error if a matching entry is not found. (Thus, if .Fa result is .Dv NULL and the return value is 0, no matching entry exists.) .Pp The .Fn setpassent function returns 0 on failure and 1 on success. The .Fn endpwent and .Fn setpwent functions have no return value. .Sh FILES .Bl -tag -width /etc/master.passwd -compact .It Pa /etc/pwd.db The insecure password database file .It Pa /etc/spwd.db The secure password database file .It Pa /etc/master.passwd The current password file .It Pa /etc/passwd A Version 7 format password file .El .Sh COMPATIBILITY The historic function .Xr setpwfile 3 , which allowed the specification of alternate password databases, has been deprecated and is no longer available. .Sh ERRORS These routines may fail for any of the errors specified in .Xr open 2 , .Xr dbopen 3 , .Xr socket 2 , and .Xr connect 2 , in addition to the following: .Bl -tag -width Er .It Bq Er ERANGE The buffer specified by the .Fa buffer and .Fa bufsize arguments was insufficiently sized to store the result. The caller should retry with a larger buffer. .El .Sh SEE ALSO .Xr getlogin 2 , .Xr getgrent 3 , .Xr nsswitch.conf 5 , .Xr passwd 5 , .Xr pwd_mkdb 8 , .Xr vipw 8 , .Xr yp 8 .Sh STANDARDS The .Fn getpwent , .Fn getpwnam , .Fn getpwnam_r , .Fn getpwuid , .Fn getpwuid_r , .Fn setpwent , and .Fn endpwent functions conform to .St -p1003.1-96 . .Sh HISTORY The .Fn getpwent , .Fn getpwnam , .Fn getpwuid , .Fn setpwent , and .Fn endpwent functions appeared in .At v7 . The .Fn setpassent function appeared in .Bx 4.3 Reno . The .Fn getpwent_r , .Fn getpwnam_r , and .Fn getpwuid_r functions appeared in .Fx 5.1 . .Sh BUGS The functions .Fn getpwent , .Fn getpwnam , and .Fn getpwuid , leave their results in an internal static object and return a pointer to that object. Subsequent calls to the same function will modify the same object. .Pp The functions .Fn getpwent , .Fn getpwent_r , .Fn endpwent , .Fn setpassent , and .Fn setpwent are fairly useless in a networked environment and should be avoided, if possible. The .Fn getpwent and .Fn getpwent_r functions make no attempt to suppress duplicate information if multiple sources are specified in .Xr nsswitch.conf 5 . diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3 index 1dd602ef58dc..a725977e5191 100644 --- a/lib/libc/gen/setproctitle.3 +++ b/lib/libc/gen/setproctitle.3 @@ -1,135 +1,134 @@ .\" Copyright (c) 1995 Peter Wemm .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, is permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice immediately at the beginning of the file, without modification, .\" this list of conditions, and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. This work was done expressly for inclusion into FreeBSD. Other use .\" is permitted provided this notation is included. .\" 4. Absolutely no warranty of function or purpose is made by the author .\" Peter Wemm. .\" 5. Modifications may be freely made to this file providing the above .\" conditions are met. .\" .\" $FreeBSD$ .\" .\" The following requests are required for all man pages. -.Dd November 13, 2020 +.Dd November 28, 2022 .Dt SETPROCTITLE 3 .Os .Sh NAME .Nm setproctitle .Nm setproctitle_fast .Nd set process title .Sh SYNOPSIS -.In sys/types.h .In unistd.h .Ft void .Fn setproctitle "const char *fmt" "..." .Ft void .Fn setproctitle_fast "const char *fmt" "..." .Sh DESCRIPTION The .Fn setproctitle library routine sets the process title that appears on the .Xr ps 1 command. The .Fn setproctitle_fast variant is optimized for high frequency updates, but may make the .Xr ps 1 command slightly slower by not updating the kernel cache of the program arguments. .Pp The title is set from the executable's name, followed by the result of a .Xr printf 3 style expansion of the arguments as specified by the .Va fmt argument. If the .Va fmt argument begins with a .Dq - character, the executable's name is skipped. .Pp If .Va fmt is NULL, the process title is restored. .Sh EXAMPLES To set the title on a daemon to indicate its activity: .Bd -literal -offset indent setproctitle("talking to %s", inet_ntoa(addr)); .Ed .Sh SEE ALSO .Xr ps 1 , .Xr w 1 , .Xr setprogname 3 , .Xr kvm 3 , .Xr kvm_getargv 3 , .Xr printf 3 .Sh STANDARDS The .Fn setproctitle function is implicitly non-standard. Other methods of causing the .Xr ps 1 command line to change, including copying over the argv[0] string are also implicitly non-portable. It is preferable to use an operating system supplied .Fn setproctitle if present. .Pp Unfortunately, it is possible that there are other calling conventions to other versions of .Fn setproctitle , although none have been found by the author as yet. This is believed to be the predominant convention. .Pp It is thought that the implementation is compatible with other systems, including .Nx and .Bsx . .Sh HISTORY The .Fn setproctitle function first appeared in .Fx 2.2 . The .Fn setproctitle_fast function first appeared in .Fx 12 . Other operating systems have similar functions. .Sh AUTHORS .An -nosplit .An Peter Wemm Aq Mt peter@FreeBSD.org stole the idea from the .Sy "Sendmail 8.7.3" source code by .An Eric Allman Aq Mt eric@sendmail.org . .Sh BUGS Never pass a string with user-supplied data as a format without using .Ql %s . An attacker can put format specifiers in the string to mangle your stack, leading to a possible security hole. This holds true even if the string was built using a function like .Fn snprintf , as the resulting string may still contain user-supplied conversion specifiers for later interpolation by .Fn setproctitle . .Pp Always use the proper secure idiom: .Pp .Dl setproctitle("%s", string); diff --git a/lib/libc/gen/tcgetpgrp.3 b/lib/libc/gen/tcgetpgrp.3 index 965416e9a50e..ca07d228afab 100644 --- a/lib/libc/gen/tcgetpgrp.3 +++ b/lib/libc/gen/tcgetpgrp.3 @@ -1,78 +1,77 @@ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)tcgetpgrp.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd November 28, 2022 .Dt TCGETPGRP 3 .Os .Sh NAME .Nm tcgetpgrp .Nd get foreground process group ID .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In unistd.h .Ft pid_t .Fn tcgetpgrp "int fd" .Sh DESCRIPTION The .Fn tcgetpgrp function returns the value of the process group ID of the foreground process group associated with the terminal device. If there is no foreground process group, .Fn tcgetpgrp returns an invalid process ID. .Sh ERRORS If an error occurs, .Fn tcgetpgrp returns -1 and the global variable .Va errno is set to indicate the error, as follows: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor. .It Bq Er ENOTTY The calling process does not have a controlling terminal or the underlying terminal device represented by .Fa fd is not the controlling terminal. .El .Sh SEE ALSO .Xr setpgid 2 , .Xr setsid 2 , .Xr tcsetpgrp 3 .Sh STANDARDS The .Fn tcgetpgrp function is expected to be compliant with the .St -p1003.1-88 specification. diff --git a/lib/libc/gen/tcgetsid.3 b/lib/libc/gen/tcgetsid.3 index 60bff8d0b98a..fdf374b1aa98 100644 --- a/lib/libc/gen/tcgetsid.3 +++ b/lib/libc/gen/tcgetsid.3 @@ -1,72 +1,71 @@ .\" Copyright (c) 2008 David Xu .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd April 15, 2008 +.Dd November 28, 2022 .Dt TCGETSID 3 .Os .Sh NAME .Nm tcgetsid .Nd get session ID associated with a controlling terminal .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In termios.h .Ft pid_t .Fn tcgetsid "int fd" .Sh DESCRIPTION The .Fn tcgetsid function returns the process group ID of the session leader for a controlling terminal specified by .Fa fd . .Sh ERRORS If an error occurs, .Fn tcgetsid returns -1 and the global variable .Va errno is set to indicate the error, as follows: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor. .It Bq Er ENOTTY The calling process does not have a controlling terminal or the underlying terminal device represented by .Fa fd is not the controlling terminal. .El .Sh SEE ALSO .Xr getsid 2 , .Xr setsid 2 , .Xr tcgetpgrp 3 , .Xr tcsetsid 3 .Sh STANDARDS The .Fn tcgetsid function conforms to .St -xpg4.2 . diff --git a/lib/libc/gen/tcsetpgrp.3 b/lib/libc/gen/tcsetpgrp.3 index d59dcf03f446..71d98ae1d467 100644 --- a/lib/libc/gen/tcsetpgrp.3 +++ b/lib/libc/gen/tcsetpgrp.3 @@ -1,95 +1,94 @@ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)tcsetpgrp.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd November 28, 2022 .Dt TCSETPGRP 3 .Os .Sh NAME .Nm tcsetpgrp .Nd set foreground process group ID .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In unistd.h .Ft int .Fn tcsetpgrp "int fd" "pid_t pgrp_id" .Sh DESCRIPTION If the process has a controlling terminal, the .Fn tcsetpgrp function sets the foreground process group ID associated with the terminal device to .Fa pgrp_id . The terminal device associated with .Fa fd must be the controlling terminal of the calling process and the controlling terminal must be currently associated with the session of the calling process. The value of .Fa pgrp_id must be the same as the process group ID of a process in the same session as the calling process. .Sh RETURN VALUES .Rv -std tcsetpgrp .Sh ERRORS The .Fn tcsetpgrp function will fail if: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor. .It Bq Er EINVAL An invalid value of .Fa pgrp_id was specified. .It Bq Er ENOTTY The calling process does not have a controlling terminal, or the file represented by .Fa fd is not the controlling terminal, or the controlling terminal is no longer associated with the session of the calling process. .It Bq Er EPERM The .Fa pgrp_id argument does not match the process group ID of a process in the same session as the calling process. .El .Sh SEE ALSO .Xr setpgid 2 , .Xr setsid 2 , .Xr tcgetpgrp 3 .Sh STANDARDS The .Fn tcsetpgrp function is expected to be compliant with the .St -p1003.1-88 specification. diff --git a/lib/libc/gen/tcsetsid.3 b/lib/libc/gen/tcsetsid.3 index d0f1d985753e..0b0facd69811 100644 --- a/lib/libc/gen/tcsetsid.3 +++ b/lib/libc/gen/tcsetsid.3 @@ -1,92 +1,91 @@ .\" Copyright (c) 2009 Ed Schouten .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd May 4, 2009 +.Dd November 28, 2022 .Dt TCSETSID 3 .Os .Sh NAME .Nm tcsetsid .Nd set session ID associated with a controlling terminal .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In termios.h .Ft int .Fn tcsetsid "int fd" "pid_t pid" .Sh DESCRIPTION The .Fn tcsetsid function sets associates a session identified by .Fa pid with a controlling terminal specified by .Fa fd . .Pp This implementation only allows the controlling terminal to be changed by the session leader itself. This implies that .Fa pid always has to be equal to the process ID. .Pp It is unsupported to associate with a terminal that already has an associated session. Conversely, it is also unsupported to associate to a terminal when the session is already associated with a different terminal. .Sh ERRORS If an error occurs, .Fn tcsetsid returns -1 and the global variable .Va errno is set to indicate the error, as follows: .Bl -tag -width Er .It Bq Er EBADF The .Fa fd argument is not a valid file descriptor. .It Bq Er ENOTTY The file descriptor represented by .Fa fd is not a terminal. .It Bq Er EINVAL The .Fa pid argument is not equal to the session ID of the calling process. .It Bq Er EPERM The calling process is not a session leader. .It Bq Er EPERM The session already has an associated terminal or the terminal already has an associated session. .El .Sh SEE ALSO .Xr getsid 2 , .Xr setsid 2 , .Xr tcgetpgrp 3 , .Xr tcgetsid 3 .Sh HISTORY A .Fn tcsetsid function first appeared in QNX. It does not comply to any standard.