[問題] fork 透過pipe 做write/read
https://gist.github.com/anonymous/203fa95d5bb48bc7a1c5
fork 後由父行程跟子行程透過 pipe 拷貝檔案
父行程使用fread讀取檔案後透過 pipe write , 由子行程從pipe read 之後寫入檔案
可是最後檔案會出現奇怪亂碼 , 可是把父行程 fread 改成 read 就正常
用fread讀 跟用 read 有什麼差異嗎?
./test a.txt b.txt
b.txt 會友奇怪亂碼
#if 1 改成 0 跑 read 函數就b.txt正常
, 請問這是什麼原因?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.58.205
※ 文章網址: https://www.ptt.cc/bbs/LinuxDev/M.1445243245.A.EB3.html
→
10/19 17:02, , 1F
10/19 17:02, 1F
→
10/19 17:03, , 2F
10/19 17:03, 2F
推
10/19 17:21, , 3F
10/19 17:21, 3F
→
10/19 17:21, , 4F
10/19 17:21, 4F
推
10/19 17:33, , 5F
10/19 17:33, 5F
→
10/19 17:33, , 6F
10/19 17:33, 6F
推
10/19 19:05, , 7F
10/19 19:05, 7F
→
10/19 19:06, , 8F
10/19 19:06, 8F
→
10/19 22:55, , 9F
10/19 22:55, 9F
LinuxDev 近期熱門文章
PTT數位生活區 即時熱門文章