opt: optimize run autostart script

This commit is contained in:
DreamMaoMao 2025-05-04 11:25:29 +08:00
parent d80fb44e72
commit fc94c44dab

View file

@ -2513,10 +2513,9 @@ void cleanup(void) {
#endif
wl_display_destroy_clients(dpy);
if (getpgid(child_pid) == child_pid) { // 检查是否是进程组 leader
kill(-child_pid, SIGTERM); // 是,则杀死整个进程组
} else {
kill(child_pid, SIGTERM); // 否,只杀死单个进程
if (child_pid > 0) {
kill(-child_pid, SIGTERM);
waitpid(child_pid, NULL, 0);
}
wlr_xcursor_manager_destroy(cursor_mgr);
@ -5035,6 +5034,7 @@ run(char *startup_cmd) {
if ((child_pid = fork()) < 0)
die("startup: fork:");
if (child_pid == 0) {
setsid();
dup2(piperw[0], STDIN_FILENO);
close(piperw[0]);
close(piperw[1]);