ics-pa is computer system project, which is a simulator to run some small game. Actually, it is a tiny os.This is the course link https://nju-projectn.github.io/ics-pa-gitbook/ics2020/.
os's Introduction
os's People
Forkers
leeyeelos's Issues
my_pstree.c可能的问题
挂掉的原因可能这几个:
void recur(char* filename){
//这个地方要做传入参数判断,保证传入的参数不能为空,否则opendir会挂
DIR *dir = opendir(filename);
printf("%s",filename);
//这个地方如果dir为空,就不能继续下面对步骤,此处应该直接返回
if(dir == NULL) fprintf(stderr,"can not open %s",filename);
struct dirent* dptr = NULL;
while(NULL!= (dptr = readdir(dir))){
if(isnumber(dptr->d_name)){
printf("%s\n","|");
printf("%s","-");
printf("%s\n",dptr->d_name);
//这个地方有风向,因为用的递归,每次调用都需要申请100字节的栈空间,如果目录非常深,就会把栈吃光
char name[100] = "./";
//task追加到 dptr->d_name后面,无法保证dptr->d_name有足够的空间容纳/task,
//空间不足会导致越界,直接挂
strcat(name,strcat(dptr->d_name,"/task"));
recur(name);
}
}
closedir(dir);
}
断是否是数字的方法还可以优化下,只要判断当前字符是‘0’ <= x <= ‘9' 就可以了或者直接使用isdigit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.