資源簡介
經典的shell實驗, 實驗內容為實驗一個unix下的簡易的shell程序, 搞懂了這個程序對于unix下的sigal機制會有一個更深入的理解, CMU大學(卡耐基 梅隆大學)經典計算機課程實驗之一, 里面含有實驗完整內容及其源程序, 還有詳細的解答過程, 很多國內大學的計算機課程都選用此實驗作為其課程設計之一!
代碼片段和文件信息
/*?
?*?myint.c?-?Another?handy?routine?for?testing?your?tiny?shell
?*?
?*?usage:?myint?
?*?Sleeps?for??seconds?and?sends?SIGINT?to?itself.
?*
?*/
#include?
#include?
#include?
#include?
#include?
#include?
int?main(int?argc?char?**argv)?
{
????int?i?secs;
????pid_t?pid;?
????if?(argc?!=?2)?{
fprintf(stderr?“Usage:?%s?\n“?argv[0]);
exit(0);
????}
????secs?=?atoi(argv[1]);
????for?(i=0;?i????????sleep(1);
????pid?=?getpid();?
????if?(kill(pid?SIGINT)?0)
???????fprintf(stderr?“kill?(int)?error“);
????exit(0);
}
- 上一篇:圖書館管理系統設計論文
- 下一篇:單片機單總線通信的自已編寫
評論
共有 條評論