linux C中调用shell命令
时间:2010-08-20 来源:chinawanglun
linux C中为我们提供了调用shell命令的函数--system
system函数调用/bin/sh 执行特定的shell命令,阻塞当前的进程知道shell命令执行完毕。 #include <stdlib.h> int system(const char *command);
执行system实际上是调用了fork函数(产生新进程)、exec函数(在新进程中执行新任务)、waitpid函数(等待新进程结束)。
system函数举例
system函数调用/bin/sh 执行特定的shell命令,阻塞当前的进程知道shell命令执行完毕。 #include <stdlib.h> int system(const char *command);
执行system实际上是调用了fork函数(产生新进程)、exec函数(在新进程中执行新任务)、waitpid函数(等待新进程结束)。
system函数举例
#include <stdio.h> |
相关阅读 更多 +