我想在C語言中爲OS項目構建一個shell。當我做重定向部分時,問題即將到來。 ls工作正常,但是當我做ls > somefile。它給我一個錯誤「ls:can not access>:沒有這樣的文件或目錄」。這裏是我的代碼部分 while(in){
argv[c]=strdup(in); \\in is output of strtok applied on input strin
我正在寫一個小殼來學習C.現在我想執行自定義命令,但它不工作。 $ ./a.out
OS>ls
10357: executing ls
failed to execute ls
: (2: No such file or directory)
我不能使用系統調用來執行自定義命令,我應該使用execvp和fork。但爲什麼它現在工作?整個代碼 #include<sys/stat.h>