TrumanWong

setsid

Run the program in a new session

Supplementary instructions

setsid command The child process inherits: SessionID, process group ID and open terminal from the parent process. If the child process wants to get rid of these, it can be achieved by calling setsid in the code. , and this can be achieved by using the command setsid to run the program on the command line or in a script. setsid helps a process detach itself from open terminals, process groups, and sessions inherited from the parent process.

grammar

setsid[options] <program> [arguments ...]

Options

-c, --ctty Set the controlling terminal as the current controlling terminal
-f, --fork always fork
-w, --wait wait for the program to exit and return with the same

Example

It can be seen that the use of setsid is also very convenient. You only need to add setsid before the command to be processed.

[root@root ~]# setsid ping www.ibm.com
[root@root ~]# ps -ef |grep www.ibm.com
root 31094 1 0 07:28 ? 00:00:00 ping www.ibm.com
root 31102 29217 0 07:29 pts/4 00:00:00 grep www.ibm.com
[root@root ~]#