说了=没说
agree

2007-10-01 00:02
盖公章。名曰“同意”

2007-10-01 08:58
2007-10-01 09:16
2007-10-01 11:31
不知你有没有念过本科,学没学一点操作系统原理的课,知不知道什么是进程。你喜欢谈shell我就跟你讨论下shell,下面是个简单的shell的实现:
程序代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
#define MAXLINE 256int main(void)
{
char buf[MAXLINE];
pid_t pid;
int status;printf(\"%%\"); //pintf prompt
while(fgets(buf,MAXLINE,stdin)!=NULL){
if(buf[strlen(buf)-1]=='\n')
buf[strlen(buf)-1]==0; //replace newline with nullif((pid=fork())<0){
printf(\"fork error\n\");
exit(1);
}
else if(pid==0){ //child process
execlp(buf,buf,(char*)0);
printf(\"couldn't execute: %s\",buf);
exit(127);
}if((pid=waitpid(pid,&status,0))<0){ //child process
printf(\"waitpid error\");
exit(1);
}
printf(\"%%\");
}
}
俺刚来,也没有什么NB的技术,只是见不得别人糊弄初学者。
[此贴子已经被作者于2007-10-1 17:44:23编辑过]

2007-10-01 17:41


2007-10-01 18:28
2007-10-01 19:11

2007-10-02 22:35
2007-10-03 02:10

2007-10-03 12:15