close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": /usr/lib/python2.7/dist-packages/libsvn/_fs.so: failed to map segment from shared object: Cannot allocate memory). Look in the Trac log for more information.
- Timestamp:
-
Jan 15, 2009, 5:31:10 PM (17 years ago)
- Author:
-
wade
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
|
v7
|
v8
|
|
| 84 | 84 | |
| 85 | 85 | }}} |
| 86 | | * FD[0] 負責 read pipe。FD[1] 負責 write pipe。 |
| 87 | | FD[1] → [PIPE] → FD[0]。 |
| | 86 | * FD[0] 負責 read pipe。FD[1] 負責 write pipe,換句話說,寫入 FD[1] 的資料可以由 FD[0] 讀取。 |
| | 87 | * 寫入 FD[1] → [PIPE] → 讀取 FD[0] 。 |
| | 88 | * 由於 FD 是 file descriptor, 非 file stream。所以為法使用 fread 和 fwrite。要使用 read 和 write 函式。 |
| 88 | 89 | * read() 會被 block 住,所以不用擔心 parent 會比 child 先結束,而導致 child 也跟著結束 (因為 child process 是依附著 parent process 而存在,依存關係可透過 pstree 查詢)。 |
| 89 | 90 | * 先使用 pipe(FD[2]),再使用 fork() 時,FD[2] 也會同時複製兩份,child 跟 parent 有各自的 FD[0]、FD[1],所以要記得關掉不必要的 FD ,兩個 processes 各自與 pipe 相接。 |
| … |
… |
|
| 91 | 92 | == Reference == |
| 92 | 93 | * [http://angkor.jazzbear.idv.tw/Linux_DivX/ Jazz 教學檔案]。 |
| 93 | | * [http://en.wikipedia.org/wiki/File_descriptor] |
| | 94 | * [http://en.wikipedia.org/wiki/File_descriptor]。 |
| | 95 | * Linux 程式設計教學手機(第三版), Richard Stones。 |
| | 96 | * LINUX 系統程式設計, Robert love。 |