system执行shell命令
system - execute a shell command
#include <stdlib.h>
int system (const char *command);
描述
system() executes a command specified in command by calling /bin/sh -c command, and returns after the command has been completed. During excution of the comman, SIGCHLD will be bocked, and SIGINT and SIGQUIT will be ignored.
返回值
错误返回-1,成功返回命令的退出状态。退出状态格式由wait指定,因此,命令的退出码是WEXITSTATUS(status). In case /bin/sh could not be executed, the exit status will be that of a command that dose exit(127).
If the value of command is NULL, system() returns nonzero if the shell is available, and zero if not.
system() does not affect the wait status of any other children.
注意
As mentioned, system() ignores SIGINT and SIGQUIT. This may make programs that call it from a loop uniterruptible, unless they take care themselves to check the exit status of the childl. E.g.
while(something) {
int ret = system("foo");
if(WIFSIGNALED(ret) && (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
break;
}
It is possible for the shell command to return 127, so that code is not a sure indication that the execve call fialed.
system执行shell命令的更多相关文章
- C语言system()函数:执行shell命令
头文件:#include <stdlib.h> 定义函数:int system(const char * string); 函数说明:system()会调用fork()产生子进程, 由子进 ...
- 在程序中执行shell命令
在linux系统下的操作中我们会经常用到shell命令来进行,一开始学习进程的时候对于shell命令也进行了思考,认为shell命令就是一个进程的外壳,经过了后来的学习对于这一点也有了更多的认识. 用 ...
- python(6)-执行shell命令
可以执行shell命令的相关模块和函数有: os.system os.spawn* os.popen* --废弃 popen2.* --废弃 commands.* ...
- Android执行shell命令
一.方法 /** * 执行一个shell命令,并返回字符串值 * * @param cmd * 命令名称&参数组成的数组(例如:{"/system/bin/cat", &q ...
- loadrunner调用plink,远程linux执行shell命令
loadrunner调用plink,远程linux执行shell命令 脚本: Action() { char* cmd; cmd = lr_eval_string("C:\\\&qu ...
- python 执行shell命令
1.os模块中的os.system()这个函数来执行shell命令 1 2 3 >>> os.system('ls') anaconda-ks.cfg install.log i ...
- python中执行shell命令的几个方法小结
原文 http://www.jb51.net/article/55327.htm 最近有个需求就是页面上执行shell命令,第一想到的就是os.system, os.system('cat /proc ...
- python中执行shell命令行read结果
+++++++++++++++++++++++++++++ python执行shell命令1 os.system 可以返回运行shell命令状态,同时会在终端输出运行结果 例如 ipython中运行如 ...
- mysq在命令行模式下执行shell命令
mysql可以在命令行模式下执行shell命令 mysql> help For information about MySQL products and services, visit: htt ...
随机推荐
- nova
chen@controller:~$ nova usage: nova [--version] [--debug] [--os-cache] [--timings] [--ti ...
- Yii2 验证码不显示
siteController 中,要将captcha 列为任意用户可以访问
- HDU 1430 魔板(康托展开+BFS+预处理)
魔板 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submis ...
- 相关css 细节处理 neat.css
人性化的细节处理 例如: textarea 默认只能垂直拖动,防止宽度改变破坏布局. textarea { resize: vertical; } 汉字字号小于 12px 不易阅读,为 <sma ...
- FastDFS安装、配置、部署
FastDFS是一个开源的,高性能的的分布式文件系统,他主要的功能包括:文件存储,同步和访问,设计基于高可用和负载均衡,FastDFS非常适用于基于文件服务的站点,例如图片分享和视频分享网站. Fas ...
- linux常用命令的英文单词缩写
命令缩写: ls:list(列出目录内容) cd:Change Directory(改变目录) su:switch user 切换用户rpm:redhat package manager 红帽子打包管 ...
- php 使用GD库上传图片以及创建缩略图
php 使用GD库上传图片以及创建缩略图 GD库是PHP进行图象操作一个很强大的库. 先在php.ini里增加一行引用:extension=php_gd2.dll 重启apache.做一个测试页 ...
- Yii源码阅读笔记(七)
接上次的组件(component)代码: /** * Returns a list of behaviors that this component should behave as. * 定义该对象 ...
- android studio无法关联源码
1.查看源码的时候报这个, 说找不到API 23的源码 2.本地的SDK 3.google stackoverflow 给出解决方案 http://stackoverflow.com/questio ...
- 批处理快速创建wifi
为什么要用cmd这种古老的东西创建wifi呢,电脑管家.360安全卫士都有这种插件,一键开启关闭,多方便啊! 开始用的也是电脑管家的免费wifi插件,但是我越来越不能忍它极慢的启动关闭过程,每一次看着 ...