特點
wait
waitpid
殭屍程序
特點:
pid_t waitpid(pid_t pid, int *status, options)
使用pipe(使用方便)
兩個程序中, 其中乙個程序讀取管道
使用pipe函式構建父子關係, 呼叫ls -l | grep a.out
demo
c int main() int i = 0; pid_t pid = 0; for (i = 0; i < 2; ++i) else if (pid == 0) } if (i == 0) else if (i == 1) else */ while (-1 != waitpid(-1, null, wnohang)) printf("over\n"); } return 0; }
int main()
int i = 0;
char buf[256];
memset(buf, 0x00, sizeof(buf));
while (1)
return 0;
}
函式* read
```c
int main()
int len = 0;
char buf[256];
memset(buf, 0x00, sizeof(buf));
while (0 != (len = read(fd, buf, sizeof(buf))))
return 0;
}```
匿名對映
兩個程序之間通訊
訊號狀態int main()
printf("讀取到的記憶體共享io區域的值為: %d", *mem);
munmap(mem, 4);
return 0;
}
訊號處理
訊號要素
posted @
2018-12-29 14:29
andrew_chan 閱讀(
...)
編輯收藏
Linux程序程式設計
一 與程序相關的系統函式 1.getpid include 提供pid t型別的定義 include 提供函式的定義 pid t getpid void 返回值為當前程序的程序id 2.getppid include 提供pid t型別的定義 include 提供函式的定義 pid getppid ...
Linux 程序程式設計
程序程式設計 1 getpid 函式的作用 獲取程序的識別碼 程序號 函式的原型 pid t getpid void 返回值 目前程序的程序號 標頭檔案 include 2 fork 函式的作用 建立乙個程序 函式的原型 pid t fork void 函式的返回值 0 出錯 0 表示當前建立的是子...
Linux程序程式設計
程序是作業系統中最基本 最重要的概念,可以說程序是作業系統結構的基礎。作業系統上任何程式的執行都離不開程序。1.程序的概念 傳統的程式本是一組指令的集合,是乙個靜態實體,無法描述程式在記憶體中的執 況,也就不能如實反映程式併發執行過程的特徵,為了深刻描述程式動態執行過程的性質,人們就引入了 程序 的...