I want to implement code which can take input from some other application.
Like say for example
ls | less
Here, less is the application/utility which takes input from ls via pipe.
I want to implement the same in C.
I Did following things
- Created PIPES using pipe command
- close local input via close(0)
- use dup2(0,fd)
- then i'm trying to read from fd abd printing on console.
When I pass like
echo "testing" | ./myapps
Can anyone suggest what am i missing?