Solved How to suppress ^C console output?

May 18, 2016 at 15:34:09
Specs: MS/PC-DOS
I have a C function to disable Ctrl+C, which works fine, except that the carat+C (^C) is still echoed to the screen.

Here's the snippet...

int flag = 0;

void ctrlchandler(int signo)
{
/* ignore Ctrl+C */
signal(signo, SIG_IGN);

/* reset handler */
signal(SIGINT, ctrlchandler);

/* increment flag */
flag++;
}

void main(void)
{
signal(SIGINT, ctrlchandler);

while(1)
{
if(flag)
{
printf("Ctrl+C pressed!\n");
flag = 0;
}
}
}

Any ideas?

Thanks in advance.


See More: How to suppress ^C console output?

Report •

#1
May 18, 2016 at 18:34:07
✔ Best Answer
I'm pretty sure you'll have to disable input echoing, and either manually echo anything the user types, or turn it on whenever you're expecting input. How you do so depends on the platform you're writing against.

How To Ask Questions The Smart Way


Report •

#2
May 18, 2016 at 19:25:43
Thanks for the quick reply. It's a DOS app I'm writing for FreeDOS with OpenWatcom 1.9. The CONIO functions in Watcom have no such functionality for suppressing echoing, but the PDCurses library does. So I'm going to go the route of building the PDCurses library for Open Watcom, and I'm going to re-write the app using PDCurses instead of CONIO.

Report •
Related Solutions


Ask Question