有2個C生成的文件,需要在開機的時候啓動。
按如下方式添加,只能啓動第一個
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
./etc/nnn1
./etc/nnn2
exit 0
然後修改成如下,也是隻能啓動前面一個
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
cd /etc
./nnn1
cd /etc
./nnn2
exit 0
多次對比測試,發現,這兩個程序都是涉及到通信,不返還的,就是不終止程序,一旦啓動就一直在運行,相當於不能退出了,所以後面的語句就無法執行了
於是採用瞭如下方式:
int main(void)
{
int i;
if ( fork() == 0 )
{
/* 子進程程序 */
system("cd /etc");
system("./nnn1");
}
else
{
system("cd /etc");
system("./nnn2");
}
}
相當於多線程運行,然後生成了一個運行文件,nnn3,在rc.loacl中添加如下:
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
chmod 777 /etc/nnn3
cd /etc
./nnn3
exit 0
開機可以同時2個程序都運行了