You can open and write to /dev/tty
in my_program
and it will be only to the terminal not to the redirected stdout.
Display output from program called between backticks
Pregunta
For an exercise about termcaps, I have to write a program that will display a list of items and let the user to select some of them. The program will then output the selected items separated with a space. The program can be called like this:
$> ./my_program foo1 foo2 foo3
or like this:
$> ls `my_program foo1 foo2 foo3`
My program works well in the first case, but in the second case, the stdout of my_program is intercepted by the backticks and will not show up on the terminal. I know that the program is running well since I got the expected result from ls if I select some items blindly.
In my program, I can't use any built-in functions excepted the following: • ioctl • tcsetattr • tcgetattr • tgetent • tgoto • tputs • tgetstr • tparm • open • close • write • malloc • free • read • exit • signal
How can I display my_program's stdout to the user when called like in the second case ?
EDIT: The only option I found is to output everything to stderr and output the selected items to stdout...
Solución