i have read a lot about what im asking, but the closest thing i have found is using the ncurses library. What im doing is a simple http client which will monitory some remote folders to check if its files have changed or if there are new files. Also, it has to check the stdin for some commands, so, I'm planning on using the father process to monitory stdin and worker process to monitory the remote directories. I would like to use something like keyboard interrupt. Something like installing a signal handler to keyboard pressing, so the user doesn't have to press enter after each command.
So far, ncurses does what i need, but i cant print stuff on stdout, but instead in stdscr. The problem with it is that this project is an assignment for college, and it is very likely to be checked through a script that read mi program's stdout...
so, any suggestions?
the relevant piece of code is:
#include <ncurses.h>
initscr(); /* Start curses mode */
raw(); /* Line buffering disabled */
noecho(); /* Don't echo() while we do getch */
char key;
while (TRUE) {
key = getch();
switch(key)
{
case 's':
printw("Instrucción recibida: STOP\n");
printf("Hasta Luego!\n");
fflush(stdout);
/*NOTICE THIS HAS NO EFFECT, */
refresh();
sleep(2);
endwin(); /* End curses mode */
fflush(stdout);
exit(0);
break;
case 'c':
printw("Instrucción recibida: CONTINUE\n");
refresh();
break;
case 'p':
printw("Instrucción recibida: PAUSE\n");
refresh();
break;
default:
printw("Instrucción desconocida recibida: %c\n",key);
refresh();
}
}
endwin(); /* End curses mode */
when i run my program, if i redirect the output to a file, i get an empty file
$ verific -d http://url.toMy.directory/ > output
$ cat output
$
Thanks for your help!!! =)