1

我写了一个程序来查看命名进程是否已经死亡,就像这样:

char *cmd = "pidof named | wc -l";
if((fp = popen(cmd , "r")) == NULL)
{
    throw;
}
fscanf(fp,"%d",&runningNum);
pclose(fp);

如果runningNum = 0,则表明没有命名进程正在运行。所以我想重新启动BIND进程。我试图sudo /etc/init.d/bind9 restart用作popen()的参数,但它不起作用。你能帮帮我吗?

4

0 回答 0