struct termios m_term;
long m_vdisable;
long m_get_vable;
char m_ret[2];
if(isatty(STDIN_FILENO)==0)
{
err_sys("Standard input is not a terminal devicd!");
return;
}
if((m_vdisable = fpathconf(STDIN_FILENO,_PC_VDISABLE)) < 0)
{
err_sys("fapthconf error or _POSIX_VDISABLE not in effect!");
return;
}
if(tcgetattr(STDIN_FILENO,&m_term)<0) //fetch tty state
err_sys("tcgetattr error");
if((m_get_vable = m_term.c_cc[VINTR]) != m_vdisable)
{
cout<<"Disable Ctrl + C?"<
else
{
cout<<"Enable Ctrl + C to interrupt?"<
cin>>m_ret;
if(strcasecmp(m_ret,"y") == 0)
{
if(m_get_vable != m_vdisable)
m_term.c_cc[VINTR] = m_vdisable; //disable INTR character
else
m_term.c_cc[VINTR] = 3; //enable INTR character to Ctrl + C
}
printf("m_get_vable=%d----m_vdisable=%d\n",m_get_vable,m_vdisable);
// m_term.c_cc[VEOF] = 2; //EOF is Control + B;
// m_term.c_cc[VEOL] = 2; //EOF is Control + B;
if(tcsetattr(STDIN_FILENO,TCSAFLUSH,&m_term)<0)
err_sys("tcsetattr error!");
}[/code]