sort讀取stdin - Linux

By Zora
at 2008-11-10T12:07
at 2008-11-10T12:07
Table of Contents
問題出在你沒有把未使用的管線末端給關掉,
造成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
--
造成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
--
Tags:
Linux
All Comments
Related Posts
請問UBUNTU是否可連GGC?

By Audriana
at 2008-11-10T12:02
at 2008-11-10T12:02
SWAP的問題

By Una
at 2008-11-10T06:42
at 2008-11-10T06:42
如何在ubuntu 8.04上看dvd

By Lauren
at 2008-11-09T23:16
at 2008-11-09T23:16
請問一下 "%" 的問題

By John
at 2008-11-09T23:12
at 2008-11-09T23:12
vmware安裝ubuntu..

By Hazel
at 2008-11-09T22:51
at 2008-11-09T22:51