我正在尝试从子进程运行闪烁命令行。例如像这样:
int hangup() {
write_on_display("line3", " ");
write_on_display("hide_icon", "DIALTONE");
write_on_display("hide_icon", "BACKLIGHT");
int pid = fork();
if (pid == 0) {
int res = execl("/usr/bin/twinkle", " ", "--immediate", "--cmd",
"answerbye", (char *) NULL);
_exit(0);
} else {
perror("hangup");
return 0;
}
return 1;
}
但闪烁变成僵尸:
10020 pts/1 Z+ 0:00 [twinkle] <defunct>
10040 pts/1 Z+ 0:00 [twinkle] <defunct>
10053 pts/1 Z+ 0:00 [twinkle] <defunct>
10064 pts/1 Z+ 0:00 [twinkle] <defunct>
10097 pts/1 Z+ 0:00 [twinkle] <defunct>
10108 pts/1 Z+ 0:00 [twinkle] <defunct>
10130 pts/1 Z+ 0:00 [twinkle] <defunct>
我试图设置信号(SIGCHLD,SIG_IGN);但没有成功。实际上我认为子进程在闪烁完成之前就死了。
从命令行运行闪烁,如:
twinkle --immediate --call 100
不会使僵尸 - 闪烁正确关闭。我在那里缺少什么?