Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of the setsid command in Linux

Shulou Source: shulou.com Published: 2022-06-01 18:01:02 09月12日 Update

This article is to share with you about the use of the setsid command in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Linux commonly used command setsid is mainly to re-create a session. The child process inherits SessionID, process group ID and open terminal from the parent process. If the child process wants to break away from the parent process, it is not controlled by the parent process.

Setsid runs the program in a new session

Add that the setsid command child process inherits from the parent process: SessionID, process group ID, and open terminal. If a child process wants to break away from this, it can be done by calling setsid in the code. The command line or script can be achieved by running the program using the command setsid. Setsid helps a process break away from open terminals, process groups, and sessions inherited from the parent process.

Syntax setsid [options] [arguments...] Option-c,-- ctty sets the control terminal to the current control terminal-f,-- fork is always fork-w,-- wait waits for the program to exit, and it is also very convenient to use the same return instance to see the use of setsid, just 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 10 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] # Thank you for reading! This is the end of this article on "what is the use of setsid commands in Linux?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Process command terminal program control content more article help run good practical same code just can pass example commonly used article read Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB OPPO Reno Shulou Technology Docker MySQL