I figured it out. But, dont know if its the right way
Create a script "run.sh" like
mknod my_pipe p
while [ $str <> "exit" ];
if [ $str == "exit" ]; then
Then, run the application (in this case bash shell) as
./run.sh | bash
This script would exit at the command "exit".
I guess there should be some better way to do it...