- 论坛徽章:
- 0
|
最近在写程序的 时候 需要增加个 cli
例如执行 restart hello
我telnet 连上 执行 后 restart hello ; 然后quit 终端就死掉了
restart hello代码 主要就是system(“killall hello”);system(“/usr/local/sbin/hello”);
后来发现system这个函数和终端有关 会 脱离
于是我换了个方法
pid_t pid;
if ((pid=fork())<0)
{
printf ("fork error");
}
else if (pid ==0)
{
setsid();
system("killall hello");
if (execv("/usr/local/sbin/hello",NULL)<0)
{
printf("hello restart error\n");
}
}
signal(SIGCHLD,SIG_IGN);
return CMD_SUCCESS;
但是这样竟然很多僵尸hello的进程 而且cli终端执行quit后还是死在那里 高不明白了
大侠们多多指教
[ 本帖最后由 vagabondyl 于 2006-5-24 16:53 编辑 ] |
|