logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

setsid.3p (3798B)


  1. '\" et
  2. .TH SETSID "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. setsid
  12. \(em create session and set process group ID
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <unistd.h>
  17. .P
  18. pid_t setsid(void);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIsetsid\fR()
  23. function shall create a new session, if the calling process is not a
  24. process group leader. Upon return the calling process shall be the
  25. session leader of this new session, shall be the process group leader
  26. of a new process group, and shall have no controlling terminal. The
  27. process group ID of the calling process shall be set equal to the
  28. process ID of the calling process. The calling process shall be the
  29. only process in the new process group and the only process in the new
  30. session.
  31. .SH "RETURN VALUE"
  32. Upon successful completion,
  33. \fIsetsid\fR()
  34. shall return the value of the new process group ID of the calling
  35. process. Otherwise, it shall return \-1 and set
  36. .IR errno
  37. to indicate the error.
  38. .SH ERRORS
  39. The
  40. \fIsetsid\fR()
  41. function shall fail if:
  42. .TP
  43. .BR EPERM
  44. The calling process is already a process group leader, or the process
  45. group ID of a process other than the calling process matches the
  46. process ID of the calling process.
  47. .LP
  48. .IR "The following sections are informative."
  49. .SH EXAMPLES
  50. None.
  51. .SH "APPLICATION USAGE"
  52. None.
  53. .SH RATIONALE
  54. The
  55. \fIsetsid\fR()
  56. function is similar to the
  57. \fIsetpgrp\fR()
  58. function of System V.
  59. System V, without job control, groups processes into
  60. process groups and creates new process groups via
  61. \fIsetpgrp\fR();
  62. only one process group may be part of a login session.
  63. .P
  64. Job control allows multiple process groups within a login session. In
  65. order to limit job control actions so that they can only affect
  66. processes in the same login session, this volume of POSIX.1\(hy2017 adds the concept of a
  67. session that is created via
  68. \fIsetsid\fR().
  69. The
  70. \fIsetsid\fR()
  71. function also creates the initial process group contained in the
  72. session. Additional process groups can be created via the
  73. \fIsetpgid\fR()
  74. function. A System V process group would correspond to a POSIX System
  75. Interfaces session containing a single POSIX process group. Note that
  76. this function requires that the calling process not be a process group
  77. leader. The usual way to ensure this is true is to create a new process
  78. with
  79. \fIfork\fR()
  80. and have it call
  81. \fIsetsid\fR().
  82. The
  83. \fIfork\fR()
  84. function guarantees that the process ID of the new process does not
  85. match any existing process group ID.
  86. .SH "FUTURE DIRECTIONS"
  87. None.
  88. .SH "SEE ALSO"
  89. .IR "\fIgetsid\fR\^(\|)",
  90. .IR "\fIsetpgid\fR\^(\|)",
  91. .IR "\fIsetpgrp\fR\^(\|)"
  92. .P
  93. The Base Definitions volume of POSIX.1\(hy2017,
  94. .IR "\fB<sys_types.h>\fP",
  95. .IR "\fB<unistd.h>\fP"
  96. .\"
  97. .SH COPYRIGHT
  98. Portions of this text are reprinted and reproduced in electronic form
  99. from IEEE Std 1003.1-2017, Standard for Information Technology
  100. -- Portable Operating System Interface (POSIX), The Open Group Base
  101. Specifications Issue 7, 2018 Edition,
  102. Copyright (C) 2018 by the Institute of
  103. Electrical and Electronics Engineers, Inc and The Open Group.
  104. In the event of any discrepancy between this version and the original IEEE and
  105. The Open Group Standard, the original IEEE and The Open Group Standard
  106. is the referee document. The original Standard can be obtained online at
  107. http://www.opengroup.org/unix/online.html .
  108. .PP
  109. Any typographical or formatting errors that appear
  110. in this page are most likely
  111. to have been introduced during the conversion of the source files to
  112. man page format. To report such errors, see
  113. https://www.kernel.org/doc/man-pages/reporting_bugs.html .