Jump to content

Terminal is messed up after exit

Go to solution Solved by Sauron,

What library are you using?

 

-edit-

I just tried this with ncurses and it works fine for me. What's the "program logic and output" you're omitting?

int main(int argc, char **argv)
{
	FILE *f = fopen("/dev/tty", "r+");
	SCREEN *screen = newterm(NULL, f, f);
	set_term(screen);
	curs_set(0);

	// some program logic and output here

	getch();

	endwin();
	delscreen(screen);
  
  	return EXIT_SUCCESS;
}
 

After exiting, the Terminal settings are not properly restored and I can't figure out how to solve this. 

The common issue, according to the internet, seems to be not calling endwin() as last action, but this doesn't work for me. I also tried without calling delscreen. And I tried applying the same to the previous screen (return value of set_term). 

 

Btw, the reason why I use newterm instead of initscr is because I need clean stdin/stdout for data processing.

 

Link to comment
Share on other sites

Link to post
Share on other sites

What library are you using?

 

-edit-

I just tried this with ncurses and it works fine for me. What's the "program logic and output" you're omitting?

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

You're right, it's working

I'm stupid 😩

I changed my CMakeLists a while ago and part of the change was a different output directory. I ran the wrong, outdated binary all the time.

 

Sry for that, I very much appreciate your effort

Link to comment
Share on other sites

Link to post
Share on other sites

14 minutes ago, EpicCrumbCake said:

You're right, it's working

I'm stupid 😩

I changed my CMakeLists a while ago and part of the change was a different output directory. I ran the wrong, outdated binary all the time.

 

Sry for that, I very much appreciate your effort

Happens to the best of us 🤷‍♂️ remember to mark the thread as solved by picking a "best answer"

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×