Linux command
setsid 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Run
setsid [program]
Run
setsid [program] > /dev/null 2>&1
Run
setsid -f [program]
Return
setsid -w [program]
Run
setsid -c [program]
说明
setsid runs a program in a new session. A session is a collection of process groups, and a new session has no controlling terminal by default. The calling process becomes the session leader. This is commonly used to detach programs from the terminal, run daemons, or ensure a process continues running after logout. When combined with output redirection, it effectively backgrounds a process independently.
参数
- -c, --ctty
- Set the controlling terminal to the current one
- -f, --fork
- Always fork, creating a new process
- -w, --wait
- Wait for the program to exit and return its exit status
- -h, --help
- Display help information
- -V, --version
- Display version information
FAQ
What is the setsid command used for?
setsid runs a program in a new session. A session is a collection of process groups, and a new session has no controlling terminal by default. The calling process becomes the session leader. This is commonly used to detach programs from the terminal, run daemons, or ensure a process continues running after logout. When combined with output redirection, it effectively backgrounds a process independently.
How do I run a basic setsid example?
Run `setsid [program]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c, --ctty do in setsid?
Set the controlling terminal to the current one