您的位置:首页 > 运维架构 > Shell

一个通用的调用shell命令及打印退出状态的C语言实现

2008-04-18 16:31 591 查看
[align=left] 1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <string.h>
5#include <sys/wait.h>
6
7
8void pr_exit(int status)
9
23int main(int argc,char** argv)
24[/align]
程序有两个功能:
1. 使用system函数调用shell命令,shell命令在启动程序参数中给出。
2. shell程序退出时可以获得其退出状态。

以上程序是根据APUE里的例子来实现的。可以参考8.6和8.13节。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: