在Linux终端打开GUI程序最完美的方法:
setsid -f <prog> <args>
注意:建议带上-f参数,否则虽然看起来和bash脱离关系了,但实际上仍然是bash子进程,bash退出时仍然会等待一段时间
如果要求等待GUI程序结束,使用:
setsid -w <prog> <args>
setsid用法:
SETSID(1) User Commands SETSID(1)
NAME
setsid - run a program in a new session
SYNOPSIS
setsid [options] program [arguments]
DESCRIPTION
setsid runs a program in a new session. The command calls fork(2) if
already a process group leader. Otherwise, it executes a program in the
current process. This default behavior is possible to override by the
--fork option.
OPTIONS
-c, --ctty
Set the controlling terminal to the current one.
-f, --fork
Always create a new process.
-w, --wait
Wait for the execution of the program to end, and return the exit
status of this program as the exit status of setsid.
-V, --version
Display version information and exit.
-h, --help
Display help text and exit.
AUTHORS
Rick Sladkey <jrs@world.std.com>
SEE ALSO
setsid(2)
REPORTING BUGS
For bug reports, use the issue tracker at
https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The setsid command is part of the util-linux package which can be
downloaded from Linux Kernel Archive
<https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.38.1 2022-05-11 SETSID(1)