问题描述
为什么ncurses在后台不起作用?
#include <iostream>
#include <ctime>
#include <unistd.h>
#include <ncurses.h>
int main () {
setlocale(LC_ALL,"");
while (true) {
time_t seconds = time(nullptr);
tm* timeinfo = localtime(&seconds);
if (timeinfo->tm_hour >= 23 || timeinfo->tm_hour <= 3) {
unsigned wait = 15 * 60;
initscr(); cbreak(); noecho();
printw("Go to bed,pls)\n");
printw("Press enter:");
int ch = getch();
while (ch == 410) {
ch = getch();
}
endwin();
sleep(wait);
continue;
}
unsigned wait = (23 - timeinfo->tm_hour) * 3600 - (60 - timeinfo->tm_min) * 60 - timeinfo->tm_sec;
sleep(wait);
}
}
但是当我在后台(./a.out&)中运行此代码时,我看不到ncurses窗口。可以解决这个问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)