Workaround for ncurses multi-thread read and write

前端 未结 1 1747
悲&欢浪女
悲&欢浪女 2020-11-30 14:32

This is what says on http://invisible-island.net/ncurses/ncurses.faq.html#multithread

If you have a program which uses curses in more than one thread,

相关标签:
1条回答
  • 2020-11-30 15:27

    Without the thread-support, you're out of luck for using curses functions in more than one thread. That's because most of the curses calls use static or global data. The getch function for instance calls refresh which can update the whole screen—using the global pointers curscr and stdscr. The difference in the thread-support configuration is that global values are converted to functions and mutex's added.

    If you want to read stdin from a different thread and run curses in one thread, you probably can make that work by checking the file descriptor (i.e., 0) for pending activity and alerting the thread which runs curses to tell it to read data.

    0 讨论(0)
提交回复
热议问题