DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

setsid(S)


setsid -- set session ID

Synopsis

   #include <sys/types.h>
   #include <unistd.h>
   

pid_t setsid(void);

Description

If the calling process is not already a process group leader, setsid sets the process group ID and session ID of the calling process to the process ID of the calling process, and releases the process's controlling terminal.

Return values

On success, setsid returns the calling process's session ID. On failure, setsid returns -1 and sets errno to identify the error.

Errors

In the following conditions, setsid fails and sets errno to:

EPERM
The calling process is already a process group leader, or there are processes other than the calling process whose process group ID is equal to the process ID of the calling process.

References

exec(S), exit(S), fork(S), getpid(S), getsid(S), intro(S), setpgid(S), setpgrp(S), signal(S), sigsend(S)

Notices

If the calling process is the last member of a pipeline started by a job control shell, the shell may make the calling process a process group leader. The other processes of the pipeline become members of that process group. In this case, the call to setsid will fail. For this reason, a process that calls setsid and expects to be part of a pipeline should always first fork; the parent should exit and the child should call setsid, thereby insuring that the process will work reliably when started by both job control shells and non-job control shells.

Considerations for threads programming

This ID number is an attribute of the containing process and is shared by sibling threads.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005