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 ...
随机推荐
- HTML&CSS----练习隐藏导航栏(三级导航)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 【贴图】网友 snoopy 用《iHMI43 液晶模块》做的界面给大家看看
请大家欣赏! iHMI43 4.3寸液晶模块购买地址: http://item.taobao.com/item.htm?id=20508376359
- 块级&行内(内联)元素
行内元素列表 <a>标签可定义锚 <abbr>表示一个缩写形式 <acronym>定义只取首字母缩写 <b>字体加粗 <bdo>可覆盖默认的 ...
- Javascript 笔记与总结(2-9)获取运行时的 style 对象
获取内存中(正在渲染)的 style 的值(非内联 style,obj.style 只能获得内联 style 的值),可以用 obj.currentStyle(低版本 IE 和 Opera 支持)和 ...
- 【IOS笔记】Resource Management in View Controllers
Resource Management in View Controllers 视图控制器的资源管理 View controllers are an essential part of managin ...
- LR性能测试脚本增强与调试
脚本增强与调试 一般来说,使用LR的Vugen录制的脚本并不能直接用于测试,需要对脚本进行各方面的增强,主要包括添加注释.关联.检查点.事务.参数化.日志输出等.下面结合刚完成的一个web项目性能测试 ...
- MySQL binlog-do-db选项是危险的
很多人通过 binlog-do-db, binlog-ignore-db, replicate-do-db 和 replicate-ignore-db 来过滤复制(某些数据库), 尽管有些使用, ...
- 3D 生物打印血管成功植入恒河猴体内
3D 生物打印血管成功植入恒河猴体内
- Shared libraries
Computer Systems A Programmer's Perspective Second Edition Shared libraries are modern innovations t ...
- java Conditions
//Listing 7-2. Achieving Synchronization in Terms of Locks and Conditions import java.util.concurren ...