看板 Linux 關於我們 聯絡資訊
問題出在你沒有把未使用的管線末端給關掉, 造成sort永遠讀不到EOF 一般的pipe使用程序應該類似以下 (這個範例省略了很多錯誤檢查的部份,是不完整的程式,請勿照抄) int fd[2]; pipe(fd); if(fork()==0){ close(fd[0]); dup2(fd[1],1); // write something to pipe }else{ close(fd[1]); dup2(fd[0],0); // read something from pipe } -- How shall my heart be unsealed unless it is broken? By Kahlil Gibran -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.8.136