我试图从 c 代码调用脚本,其中脚本文件杀死应用程序并重新启动
/* testApp.c */
int main()
{
int data;
printf("Enter the data\n");
scanf("%d",&data);
/* Invoke the script file */
system("script.sh");
}
下面是脚本文件
#!/bin/sh
pkill testApp
start-stop-daemon --start --user root --name testApp --startas testApp -- --daemon
pidof testApp
if [ $? == 0 ]
then
echo "Restart of testApp success!!"
else
echo "Restart of testApp failed!!"
exit 1
fi
exit 0
当应用程序执行时,它终止正在运行的进程并重新启动应用程序,但它并不在scanf等待用户输入,只是继续执行 如果从脚本文件调用,为什么应用程序不等待用户输入