system和popen
发布日期:2021-05-10 13:48:07 浏览次数:20 分类:精选文章

本文共 2227 字,大约阅读时间需要 7 分钟。

������

������������������������

#include "stdlib.h"

#include "sys/wait.h"

#include "sys/types.h"

int system(const char *command);

������������������

���������������������������������������������

������fork������������������������������fork���������������������-1���

���������������������shell������

������������execl������������/bin/sh���������������������������������������"sh -c command"���

���������������������������������shell������������������status������8-15���������������������������

������������������������������������

������waitpid������������������������������������������������������������status���������8-15���������������������������

������������������������������������������������������������������������

���������������

system������������������������

-1���������������

0������������������������������������

>0���������������������������������������������PID

���������������������

������������������

wifexited(status)������������������������������������

wexitstatus(status)������������������������������������

wifsigENDED(status)���������������������������������

wtermigd(status)���������������������������

wifstopped(status)������������������������������������������

wstopsig(status)������������������������������������

������������������

������system()���������SIGCHLD���������������������SIGINT���SIGQUIT���������������������

���������������������������I/O���������������������������������

������������������

������������������������������������������

#include "stdio.h"

#include "stdlib.h"

#include "sys/wait.h"

#include "sys/types.h"

int main(int argc, char **argv) {

int ret = 0;

ret = system(command);

if (ret == -1) {

printf("system������������\n");

} else {

/* ��������������������������� */

}

上一篇:Shell系列--技巧
下一篇:Linux命令--其他命令

发表评论

最新留言

不错!
[***.144.177.141]2025年04月29日 08时52分38秒