| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- create session and set process group ID
#include <sys/types.h>#include <unistd.h>pid_tsetsid(void);
Thesetsid() function creates a new session, if the calling process isnot a process group leader. Upon return the calling process will bethe session leader of this new session, will be the process groupleader of a new process group, and will have no controlling terminal. Theprocess group ID of the calling process will be set equalto the process ID of the calling process. The calling process willbe the only process in the new process group and the onlyprocess in the new session.
Upon successful completion,setsid() returns the value of the process group ID of the calling process. Otherwise it returns(pid_t)-1 and setserrnoto indicate the error.
Thesetsid() function will fail if:
The calling process is already a process group leader, or the process group ID of a process other than the calling process matches the process ID of the calling process.
Seeattributes(5) for descriptions of the following attributes:
|
getsid(2),setpgid(2),setpgrp(2),attributes(5),standards(5)
A call tosetsid() by a process that is a process groupleader will fail. A process can become a process group leader bybeing the last member of a pipeline started by a job controlshell. Thus, a process that expects to be part of a pipeline,and that callssetsid(), should always first fork; the parent should exit andthe child should callsetsid(). This will ensure that the calling processwill work reliably when started by both job control shells and non-jobcontrol shells.
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |