一个简单地Shell-like 的实现
来源:互联网 发布:天刀女性明星捏脸数据 编辑:程序博客网 时间:2024/05/01 04:28
下面的一个程序是shell的简单实现,虽然简单,但是原理是相同的。请仔细体会。
//shell-like function
#include "apue.h"
#include <sys/wait.h>
int main(int argc,char *argv[])
{
char buf[MAXLINE];
pid_t pid;
int status;
printf("%% ");
while (fgets(buf, MAXLINE,stdin) != NULL)
{
if (buf[strlen(buf)-1] =='\n')
{
buf[strlen(buf)-1] =0;
}
if ((pid = fork()) <0)
{
printf("err\n");
}
elseif (pid == 0)/* child */
{
execlp(buf, buf, (char *)0);
exit(127);
}
/* parent */
if ((pid = waitpid(pid, &status,0)) < 0)
{
printf("error\n");
}
printf("%% ");
}
return(0);
}
- 一个简单地Shell-like 的实现
- 实现一个简单的shell
- 关于一个简单的shell的实现
- Linux编程实现一个简单的Shell
- 【Linux】实现一个简单的shell
- Linux.实现一个简单的shell
- 【Linux】实现一个简单的shell
- 自主实现一个简单的shell
- 如何实现一个简单地Filter
- C++自己实现一个简单地Vector
- 一个简单的shell
- 一个简单的shell
- shell实现一个简单进度条
- 用c语言的实现一个简单的交互式shell
- 一个简单地ViewPager自定义的轮播图
- 实现简单的shell
- 实现简单的shell
- 用Qt实现一个简单的shell (Qt5+V8)
- 遍历数组、数组排序
- 1089-1096
- UEditor扩展上传
- OC可变数组的创建与简单应用
- Android ORMLite 框架的入门用法
- 一个简单地Shell-like 的实现
- 第四天学习笔记
- OC中可变字典和不可变字典
- Dynamics CRM2015 The plug-in type does not exist in the specified assembly问题的解决方法
- 机房收费之查看数据库代码
- 开源 java CMS - FreeCMS2.3会员我的留言
- this call() apply()理解
- Android 常用设计模式(一)
- iOS找色块游戏