c - 如何从 ac 程序并行执行脚本
问题描述
我想从 ac 程序中执行一个脚本,我希望它应该并行运行。所以为此我写了这段代码。
#include <stdio.h>
main()
{
pthread_t hwdiagT;
if(pthread_create(&hwdiagT, NULL, &hwdiagScriptExecution, NULL) == ERROR)
{
printf("%s():pthread_cretation failed for hwdiag script execution",__func__);
}
}
void *hwdiagScriptExecution()
{
/* run diags after rpd hw is up*/
FILE *pp;
pp=popen("/usr/bin/hwdiag allquick", "w");
if ( pp == NULL ) {
printf("ERROR: Couldn't run hardware diagnostics.");
}
else {
pclose(pp);
}
return NULL;
}
对于并行执行,我尝试将脚本放在一个线程中,但似乎它不起作用。看起来这个线程被阻塞,直到整个脚本执行。有什么方法可以实现脚本的这种并行执行。
解决方案
推荐阅读
- php - PHP strtotime 不使用 mysql 值执行类似的转换
- wordpress - TinyMCE 是否允许不可变实体(CKEditor 的“小部件”功能的对应物)?
- mysql - 内连接没有匹配的列
- javascript - 回调函数抛出错误
- java - ArrayAdapter 中的 getView() 表示第 1 行是位置 0 而不是正确的位置 1
- laravel - Eloquent 关系数据透视表与 3 模型
- ios - 重新启动应用程序 swift 4 时,UserDefaults 有时不保留保存的值
- r - 如何在表格中构造 Web 数据
- python - Linux 上 VSCode 中 Python 的 VSCode-Python 大纲视图不起作用
- c# - 列表
> 使用 linq 操作数据