23,120
社区成员
发帖
与我相关
我的任务
分享
int execute(const char *filename, const char *argv[])
{
pid_t pid = -1;
if (0 == (pid = fork())) {
execvp(filename, (char * const *) argv);
getsystime(strtime);
exit(127);
} else if (0 < pid) {
int status = -1;
wait(&status);
return status;
} else {
getsystime(strtime);
return pid;
}
return 0;
}
background_cmd &
my_pid=$!
# ...
# ...
wait $my_pid
status=$?
完全没有办法和C code整合起来。