Hi,
I have done my own application console with scanf(). When I run in the screen
(screen -mS test ./test), it work as expected with each characters printed. But
when I run it in screen as daemon, it's failing in loop:
$ screen -dmS test ./test
$ screen -r test
stdin_thread scanf failed! ret: -1
stdin_thread scanf failed! ret: -1
Do you have any clue on how I can make this work in deamon mode?
Here is my sample code:
```
#include <stdio.h>
#include <errno.h>
#include <termios.h>
#include <unistd.h>
void enableRawMode()
{
#ifdef __linux__
struct termios raw;
// Get current terminal attributes
tcgetattr(STDIN_FILENO, &raw);
// Modify terminal attributes for raw mode
raw.c_lflag &= ~(ECHO | ICANON);
// Set modified attributes
tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
#endif
}
int main() {
enableRawMode();
char c;
while (1) {
int ret = scanf("%c", &c);
if ( ret > 0) {
printf("%c", c);
} else {
printf("stdin_thread scanf
failed! ret: %d\n", ret);
}
}
return 0;
}
```
Michael