关于system 调用shell 产生sh进程,如何把sh进程关掉...
#include <stdio.h>
void amendHeadOfConfig(int number)
{
char commandStr[40];
sprintf(commandStr,"sed \'1 c %d\' 1.txt > temp.txt",number);
printf("commandStr: %s\n",commandStr);
system(commandStr);
system("rm -f 1.txt");
system("mv temp.txt 1.txt");
}
int main()
{
amendHeadOfConfig(5);
while(1);
}
每次调用system 都会产生一个sh的进程。如果程序不退出 就会一直产生sh的进程。
怎样才能在退出之前把由system调用sh的进程退出掉。
如上面的程度。我看ps的时候一直会有三个sh在跑..
如何调用一个system后,相应的sh进程也退出呢???
请赐教..