91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

操作系統(tǒng)第七版 第三章進(jìn)程 課后編程項(xiàng)目 操作系統(tǒng)實(shí)驗(yàn)二_shell的簡(jiǎn)單實(shí)現(xiàn)。 實(shí)現(xiàn)了以下功能: (1)解析用戶提交的命令行;按照環(huán)境變量搜索目錄系統(tǒng);執(zhí)行命令。 (2)提供ls、mkdir rmdir、pwd、ps等命令。 (3)提供歷史查詢功能。如用戶按下Ctr1+C,信號(hào)處理器將輸出最近的10個(gè)命令列表。

資源截圖

代碼片段和文件信息

/**
?*Name:?Command?Shell?History
?*Author:?Misky
?*Date:?2013/10/25
?*Explanation:?This?is?a?project?which?can?get?the?shell?command?from?user?and?execute?it?in?the?child?process?
???????????????and?the?latest?10?commands?will?be?saved.?Some?special?requirements?as?follows?have?also?be?completed?in?this?project.
???????????????1.When?user?enters?in?“Ctrl+D“?the?project?will?be?terminated.
???????????????2.When?user?enters?in?“Ctrl+c“?the?list?of?10?historys?will?be?displayed.?I?here?displayed?it?like?a?queue?or?like?a?Gluttonous?Snake.
???????????????3.If?a?command?uses?a?“&“?as?its?last?character?the?parent?process?will?not?wait?for?the?child?process
?????????????????i.e.?user?will?be?asked?to?type?in?another?command?without?the?completion?of?the?last?one.
???????????????4.When?user?uses?command?“r“?only?the?last?command?in?history?list?will?be?executed?again.?
?????????????????And?in?this?case?if?the?last?command?is?wrong?it?will?not?be?put?in?the?history.?Otherwise?it?will.
???????????????5.When?user?uses?command?“r?x“?the?nearset?command?with?first?character?“x“?in?history?list?will?be?executed?again.?
?????????????????And?also?in?this?case?if?that?command?is?wrong?it?will?not?be?put?in?the?history.?Otherwise?it?will.
?*PS:Before?running?this?project?you?need?to?create?a?txt?file?named?“success.txt“?in?directory?“/home/ieee/“.
?????If?you?don‘t?have?that?kind?of?directory?you?need?to?change?the?path?to?your?path?respectively?in?line?136159180266280?and?288.
?????I?know?that?we?can?create?a?file?atomatically?in?C?but?since?this?is?between?the?parent?process?and?the?child?process?if?I?do?that?a?new?file?will?be?created?in?both?child?process?memory?and?the?father‘s?which?will?cause?the?inconformity?although?it?is?inconvenient.
?????And?remember?to?make?your?path?destination?already?get?the?root?to?be?read?and?write.?Thank?you!
?*/

#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?

#define?MAX_LINE?80?
#define?BUFFER_SIZE?50

void?getPrompt();
char?buffer[BUFFER_SIZE];
char?*history[10][10];???????????????????/*save?10?latest?commands*/
int?nextPosition=0;??????????????????????/*the?position?where?next?command?could?be?put?in*/
int?CommandLenth[10]={0};????????????????/*the?lenth?of?each?command?in?history*/
void?ProcessRCommand(char?*args[]);??????/*the?function?to?deal?with?the?“r“?command*/
int?success[10]={1111111111};???/*indicate?each?command?in?history?is?right?or?wrong?1?means?right*/
int?flag=1;??????????????????????????????/*used?to?tell?the?child?process?whether?the?nextPosition?needs?to?be?changed?or?not?*/?
FILE?*fp;?????????????
static?char?promptbuf[MAX_LINE];?????????//?store?prompt

/*setup()?reads?in?the?next?command?line?separating?it?into?distinct?tokens?using?whitespace?as?delimiters.?*/
void?setup(char?inputBuffer[]?char?*args[]int?*bac

評(píng)論

共有 條評(píng)論