setsid command in Linux with Examples
setsid command in Linux system is used to run a program in a new session. The command will call the fork(2) if already a process group leader. Else, it will execute a program in the current process.
Syntax:
setsid [options] program [arguments]
Example: It will execute our shell script in a new session.
Options:
- setsid -c: This option will set the controlling terminal to the current one.
Example:
sudo setsid -c ./add.sh
In this example, we have our current terminal set to controlling terminal.
- setsid -w: This option will wait for the execution of the program to end and return the exit value of this program as the return value of setsid.
Example:
setsid -w ./add.sh
In this example, if there’s any process which is supposed to take some time to be fully executed then, in that case, it will return the exit value.
- setsid -V : This option will show the version information and exit.
Example:
setsid -V
- setsid -h : This option will show the help text and exit.
setsid -h
Recommended Posts:
- atd command in Linux with examples
- tar command in Linux with examples
- cpp command in Linux with Examples
- env command in Linux with Examples
- wc command in Linux with examples
- dir command in Linux with examples
- bc command in Linux with examples
- w command in Linux with Examples
- gcc command in Linux with examples
- mv command in Linux with examples
- cc command in Linux with Examples
- sum command in Linux with Examples
- cd command in Linux with Examples
- cvs command in Linux with Examples
- tac command in Linux with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.








