Blame man-pages-posix-2013-a/man3p/setsid.3p

Packit 7cfc04
'\" et
Packit 7cfc04
.TH SETSID "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
Packit 7cfc04
.SH PROLOG
Packit 7cfc04
This manual page is part of the POSIX Programmer's Manual.
Packit 7cfc04
The Linux implementation of this interface may differ (consult
Packit 7cfc04
the corresponding Linux manual page for details of Linux behavior),
Packit 7cfc04
or the interface may not be implemented on Linux.
Packit 7cfc04
Packit 7cfc04
.SH NAME
Packit 7cfc04
setsid
Packit 7cfc04
\(em create session and set process group ID
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.LP
Packit 7cfc04
.nf
Packit 7cfc04
#include <unistd.h>
Packit 7cfc04
.P
Packit 7cfc04
pid_t setsid(void);
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
\fIsetsid\fR()
Packit 7cfc04
function shall create a new session, if the calling process is not a
Packit 7cfc04
process group leader. Upon return the calling process shall be the
Packit 7cfc04
session leader of this new session, shall be the process group leader
Packit 7cfc04
of a new process group, and shall have no controlling terminal. The
Packit 7cfc04
process group ID of the calling process shall be set equal to the
Packit 7cfc04
process ID of the calling process. The calling process shall be the
Packit 7cfc04
only process in the new process group and the only process in the new
Packit 7cfc04
session.
Packit 7cfc04
.SH "RETURN VALUE"
Packit 7cfc04
Upon successful completion,
Packit 7cfc04
\fIsetsid\fR()
Packit 7cfc04
shall return the value of the new process group ID of the calling
Packit 7cfc04
process. Otherwise, it shall return \(mi1 and set
Packit 7cfc04
.IR errno
Packit 7cfc04
to indicate the error.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
The
Packit 7cfc04
\fIsetsid\fR()
Packit 7cfc04
function shall fail if:
Packit 7cfc04
.TP
Packit 7cfc04
.BR EPERM
Packit 7cfc04
The calling process is already a process group leader, or the process
Packit 7cfc04
group ID of a process other than the calling process matches the
Packit 7cfc04
process ID of the calling process.
Packit 7cfc04
.LP
Packit 7cfc04
.IR "The following sections are informative."
Packit 7cfc04
.SH EXAMPLES
Packit 7cfc04
None.
Packit 7cfc04
.SH "APPLICATION USAGE"
Packit 7cfc04
None.
Packit 7cfc04
.SH RATIONALE
Packit 7cfc04
The
Packit 7cfc04
\fIsetsid\fR()
Packit 7cfc04
function is similar to the
Packit 7cfc04
\fIsetpgrp\fR()
Packit 7cfc04
function of System V.
Packit 7cfc04
System V, without job control, groups processes into
Packit 7cfc04
process groups and creates new process groups via
Packit 7cfc04
\fIsetpgrp\fR();
Packit 7cfc04
only one process group may be part of a login session.
Packit 7cfc04
.P
Packit 7cfc04
Job control allows multiple process groups within a login session. In
Packit 7cfc04
order to limit job control actions so that they can only affect
Packit 7cfc04
processes in the same login session, this volume of POSIX.1\(hy2008 adds the concept of a
Packit 7cfc04
session that is created via
Packit 7cfc04
\fIsetsid\fR().
Packit 7cfc04
The
Packit 7cfc04
\fIsetsid\fR()
Packit 7cfc04
function also creates the initial process group contained in the
Packit 7cfc04
session. Additional process groups can be created via the
Packit 7cfc04
\fIsetpgid\fR()
Packit 7cfc04
function. A System V process group would correspond to a POSIX System
Packit 7cfc04
Interfaces session containing a single POSIX process group. Note that
Packit 7cfc04
this function requires that the calling process not be a process group
Packit 7cfc04
leader. The usual way to ensure this is true is to create a new process
Packit 7cfc04
with
Packit 7cfc04
\fIfork\fR()
Packit 7cfc04
and have it call
Packit 7cfc04
\fIsetsid\fR().
Packit 7cfc04
The
Packit 7cfc04
\fIfork\fR()
Packit 7cfc04
function guarantees that the process ID of the new process does not
Packit 7cfc04
match any existing process group ID.
Packit 7cfc04
.SH "FUTURE DIRECTIONS"
Packit 7cfc04
None.
Packit 7cfc04
.SH "SEE ALSO"
Packit 7cfc04
.IR "\fIgetsid\fR\^(\|)",
Packit 7cfc04
.IR "\fIsetpgid\fR\^(\|)",
Packit 7cfc04
.IR "\fIsetpgrp\fR\^(\|)"
Packit 7cfc04
.P
Packit 7cfc04
The Base Definitions volume of POSIX.1\(hy2008,
Packit 7cfc04
.IR "\fB<sys_types.h>\fP",
Packit 7cfc04
.IR "\fB<unistd.h>\fP"
Packit 7cfc04
.SH COPYRIGHT
Packit 7cfc04
Portions of this text are reprinted and reproduced in electronic form
Packit 7cfc04
from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
Packit 7cfc04
-- Portable Operating System Interface (POSIX), The Open Group Base
Packit 7cfc04
Specifications Issue 7, Copyright (C) 2013 by the Institute of
Packit 7cfc04
Electrical and Electronics Engineers, Inc and The Open Group.
Packit 7cfc04
(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
Packit 7cfc04
event of any discrepancy between this version and the original IEEE and
Packit 7cfc04
The Open Group Standard, the original IEEE and The Open Group Standard
Packit 7cfc04
is the referee document. The original Standard can be obtained online at
Packit 7cfc04
http://www.unix.org/online.html .
Packit 7cfc04
Packit 7cfc04
Any typographical or formatting errors that appear
Packit 7cfc04
in this page are most likely
Packit 7cfc04
to have been introduced during the conversion of the source files to
Packit 7cfc04
man page format. To report such errors, see
Packit 7cfc04
https://www.kernel.org/doc/man-pages/reporting_bugs.html .