Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

setsid(2) [opendarwin man page]

SETSID(2)						      BSD System Calls Manual							 SETSID(2)

NAME
setsid -- create session and set process group ID SYNOPSIS
#include <sys/types.h> #include <unistd.h> pid_t setsid(void); DESCRIPTION
The setsid function creates a new session. The calling process is the session leader of the new session, is the process group leader of a new process group and has no controlling terminal. The calling process is the only process in either the session or the process group. Upon successful completion, the setsid function returns the value of the process group ID of the new process group, which is the same as the process ID of the calling process. ERRORS
If an error occurs, setsid returns -1 and the global variable errno is set to indicate the error, as follows: [EPERM] 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. SEE ALSO
setpgid(3), tcgetpgrp(3), tcsetpgrp(3) STANDARDS
The setsid function is expected to be compliant with the IEEE Std 1003.1-1988 (``POSIX.1'') specification. BSD
June 4, 1993 BSD

Check Out this Related Man Page

SETSID(2)						     Linux Programmer's Manual							 SETSID(2)

NAME
setsid - creates a session and sets the process group ID SYNOPSIS
#include <unistd.h> pid_t setsid(void); DESCRIPTION
setsid() creates a new session if the calling process is not a process group leader. The calling process is the leader of the new session, the process group leader of the new process group, and has no controlling terminal. The process group ID and session ID of the calling process are set to the PID of the calling process. The calling process will be the only process in this new process group and in this new session. RETURN VALUE
On success, the (new) session ID of the calling process is returned. On error, (pid_t) -1 is returned, and errno is set to indicate the error. ERRORS
EPERM The process group ID of any process equals the PID of the calling process. Thus, in particular, setsid() fails if the calling process is already a process group leader. CONFORMING TO
SVr4, POSIX.1-2001. NOTES
A child created via fork(2) inherits its parent's session ID. The session ID is preserved across an execve(2). A process group leader is a process with process group ID equal to its PID. In order to be sure that setsid() will succeed, fork(2) and _exit(2), and have the child do setsid(). SEE ALSO
setsid(1), getsid(2), setpgid(2), setpgrp(2), tcgetsid(3), credentials(7) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2013-02-11 SETSID(2)
Man Page

15 More Discussions You Might Find Interesting

1. Programming

Why process leader can not call setsid()

Why process leader can not call setsid() (2 Replies)
Discussion started by: chenhao_no1
2 Replies

2. UNIX for Dummies Questions & Answers

permission

Is it possible to set owner to a group? I need to have a group own a process, because there will be 3 diffrent persons that will start and stop this process. They can not use the same users cause och back logging. we need to know who end when a certian user start/stops processes. (1 Reply)
Discussion started by: dozy
1 Replies

3. Programming

How to create constantly running process

Ther are two process in my program and i want both to constantly running. So i have written the following code. But one of this process which is calling function wsJobCheck() is getting terminated with giving message : Program exited normally. Can any one suggest why this is happing. Code : ... (1 Reply)
Discussion started by: bhakti
1 Replies

4. UNIX for Dummies Questions & Answers

which process writes to file

Some process rewrites a file ( i'm hacked :) Can I somehow monitor which process does that? (2 Replies)
Discussion started by: hachik
2 Replies

5. UNIX for Dummies Questions & Answers

To identify process

i want a command to display all the process running for partical user and in all process i want to see only particular process details.. pls suggest comand like ps -ef (1 Reply)
Discussion started by: Babu154
1 Replies

6. UNIX for Dummies Questions & Answers

How to know the i/o of a process

Hello guys, i need to know how much i/o have a process?, for example when y use the command 'top' i have the i/o value in general of all process but i need to know only the i/o measure of a particular process. (1 Reply)
Discussion started by: lestat_ecuador
1 Replies

7. Programming

how to delay a process from getting killed

We are forking a process B from process A and the process B should display the details it reads from process C(daemon process) continuously. Let us say that the process C sents 100 packets.The process B receives all the 100 packets from the process C before it prints all details of 31... (1 Reply)
Discussion started by: cijkmysj
1 Replies

8. Solaris

How to know about a hanged process

Hi, My process is visible in 'ps' command but actually it is not working or it got hanged. This process is not generating any log. Now How can I know that my process got hanged. Please help. (2 Replies)
Discussion started by: sanjay1979
2 Replies

9. Solaris

Number of process per user session

Hi All, Do we have any option through which we can limit the number of process which can be started by single user session. Thanks (3 Replies)
Discussion started by: kumarmani
3 Replies

10. AIX

Need explanation of 'who -d' output

Can someone tell me what the output of 'who -d' is ? What's causing the process in the list to be there ? What can be done to get rid of / fix those process ? Are those process simple problems, important or urgent onces ? I am asking because while looking for another 'who' option, I... (2 Replies)
Discussion started by: Browser_ice
2 Replies

11. Shell Programming and Scripting

process tree

how to draw a process tree if i know my process id and how can i identify session leaders (1 Reply)
Discussion started by: annapurna konga
1 Replies

12. UNIX for Advanced & Expert Users

Unix process states

I am trying to write my own Unix compliant (SUSv4) OS - Just a hobby OS, nothing serious. While going through the standard, I couldn't find any explicit information on process states. What I could find was (excluding the real-time considerations)- From this it can be inferred that the... (2 Replies)
Discussion started by: tinkerbeast
2 Replies

13. UNIX for Dummies Questions & Answers

Restarting a process

Hi, How is it possible to restart only your process. I can get the process killed but I am not able to start it. For eg : i first did this ps -ef|grep _out --displays all the process with _out in the name then I killed kill -15 36044 -- process id. Now how can i start the same... (1 Reply)
Discussion started by: TH3M0Nk
1 Replies

14. Programming

Create a group of process

Hi all ! :) What I want? 1. All child process must be in the same group of process. Parent is a leader of the group. How to do this? I would be greatfull of some example of code, I read about setsid but I can't even start... My code so far: #include <stdio.h> #include <stdlib.h>... (2 Replies)
Discussion started by: mattdj
2 Replies

15. Shell Programming and Scripting

Work with setsid to open a session and close it correctly

I would like to create the following script: run a python script with setsid python may or may not fail with exception check if all of the group processes were terminated correctly if not, kill the remaining processes How can I do that? Thanks a lot (3 Replies)
Discussion started by: ASF Studio
3 Replies