To: DJGPP List Subject: Re: suppressing ctrl-c Reply-To: pgf AT Cayman DOT COM Date: Thu, 27 Jan 94 12:50:08 EST From: Paul Fox > > > but i still can't figure out how to suppress ctrl-c. > > As I remember it there's even a c function, setcbrk (), that can be used; > anyway that's what I did for Emacs. > > When you are setting the Break mode (or the stdout mode) you should take > care to restore them before exiting; otherwise the next program may act > a little funny. > well, setcbrk(0) certainly does what i asked -- i no longer get killed when there's no read outstanding. i'm not quite happy with this, however. i'd rather be informed via a callback that the user has entered ctrl-c, much the way i can be informed of ctrl-break when i use _go32_want_ctrl_break()/_go32_was_ctrl_break_hit(). is there any reason in principle that the following code shouldn't work? it doesn't seem to. is there something basically different between the way ctrl-c and ctrl-break handlers are invoked, that i'm missing here? (this was copied/edited directly from the code for the want/was_ctrl_break routines.) paul fox, pgf AT cayman DOT com #include #include #include #include static _go32_dpmi_registers regs; static volatile u_long ctrl_c_count = 0; static int ctrl_c_hooked = 0; static _go32_dpmi_seginfo old_vector; static _go32_dpmi_seginfo new_vector; u_long was_ctrl_c_hit(); void want_ctrl_c(int yes); /* auto-yes if call above function */ static void ctrl_c_isr(_go32_dpmi_registers *regs) { ctrl_c_count ++; } u_long was_ctrl_c_hit() { u_long cnt; want_ctrl_c(1); cnt = ctrl_c_count; ctrl_c_count = 0; return cnt; } void want_ctrl_c(int yes) { if (yes) { if (ctrl_c_hooked) return; _go32_dpmi_get_real_mode_interrupt_vector(0x23, &old_vector); new_vector.pm_offset = (int)ctrl_c_isr; _go32_dpmi_allocate_real_mode_callback_iret(&new_vector, ®s); _go32_dpmi_set_real_mode_interrupt_vector(0x23, &new_vector); ctrl_c_count = 0; ctrl_c_hooked = 1; } else { if (!ctrl_c_hooked) return; _go32_dpmi_set_real_mode_interrupt_vector(0x23, &old_vector); _go32_dpmi_free_real_mode_callback(&new_vector); ctrl_c_count = 0; ctrl_c_hooked = 0; } }