Handling keyboard interrupts in QNX

Hello all,

I have an issue when I handle the keyboard interrupt (interrupt number 1) in my application
After servicing the interrupt and closing the application the QNX shell stops receiving keyboard inputs.

The code is as follows

InterruptAttachEvent (1, sigevent…)

InterruptWait (NULL, NULL);

InterruptMask ()
InterruptDetach ()

Does anyone know of a fix?

Any help will be greatly appreciated.

Regards,
-Sameer

InterruptMask is called leaving the interrupt disabled. The OS needs that interrupt to handle the keyboard properly.

Why do you need to attach to the keyboard interrupt?

Hi,

Even when I donot call the interrupt mask or interrupt detach, I get the same effect of shell not receiving the keyboard interrupt after the application exits.

What I am doing is tring to simulate a hardware interrupt like the powerfail. The interrupt number is a custom one. As I do not have the hardware yet, thenext best thing was the key board. I am using the keyboard to simulate the power fail interrupt.

Is there any other way to generate a hardware interrupt?

Regards,
-Sameer

If you set up the interrupt to deliver a pulse then it’s very easy to simulate. Any process can send a pulse.

Look at InterruptAttachEvent() and the associated docs on writing an interrupt handler.

There is probably something in your code that you not telling us about that is causing the problem.

Hello,

Thanks for your help. The issue is resolved. The issue got resolved when I called the InterruptUnmask when exiting the application.

Regards,
-Sameer

Woops I kind of miss that. When the kernel received the interrupt it disables it, it’s up to the application to enable it.

You should always use _NTO_INTR_FLAGS_TRK_MSK - that way the OS keeps track of the mask/unmask count and will do the appropriate cleanup if your process exits.

Colin, the doc on InterruptDetach should probably make that clear, (not only in InterruptAttach*().

Cheers,

Thanks for the information on _NTO_INTR_FLAGS_TRK_MSK flag. I am using this and I am able to simulate the hardware interrupt.

Thanks once again :slight_smile: