Archived(CSE)/시스템 프로그래밍
Chap 10. I/O Redirection and Pipes
bale.yoon
2018. 11. 18. 16:33
Chap 10. I/O Redirection and Pipes
* CLI Communication by I/O and PIPES
* cmd $ Comm A B -> print difference
1) A & !B
2) B & !A
3) A & B
* The ">" operator can be used to treats files as variables of arbitrary size and structure
( cmd > writeFile , cmd < ReadFile )
* Fd - stdin 0 stdout 1 stderr 2 (FIXNUM)
* If we open file -> then we receive "THE LOWEST FD"
* Shell $ CMD > FD
then, if you write stdout in code.c, but then we write FD.
in SHELL process stdout -> FD
* How to Attach stdin to FILE
1) Close and Then
2) open..close..dup..close Method3
3) open..dup2..close
* Execute (by fork) -> in child process fd
* Pipe - one Way channel to communicate with File
pipe(int fdArr[2])