Detecting interruptions in C

Hi. You may know how to detect when a interruption succeeded programming in C. Just like receiving a signal without blocking. Knowing when it was a keystroke (IRQ 2), or a mouse movement (12), or a disk access, etc. and getting actually for example the letter typed.

Thanks a lot.

With what operating system, environment, hardware etc?

If you are talking about DOS, just stick in a simple TSR with redirector, if you are talking about a more complex OS it's a driver responsibility.

Out of interest, why, as a program, would you care whether a disk access has occurred?

Working on Linux. But it shouldn't matter. There is not a standard C routine to know when a interruption succeeded? A way to handle signals/events generated from interruptions, for example.

I want to know this to implement a random bit generator. You have to check different sources like the time delaying between keystrokes or maybe the change of the temperature.

No. The standard C library works at a much higher level. Signal only refers to your process.

You could open an HTTP connection to a weather site.....?

I am just asking for an API, like in Unix the system calls are wrapped in C functions. If there isn't something like this, do you know a library to solve it?

If I was on Solaris 9 and above I would just use "/dev/random" and be done.

rand(3): pseudo-random number generator - Linux man page

I know the existence of /dev/random. I just wanna play with the sources by myself, mixing them, etc. But I just don't how to get that information. I have seen some OpenGL libraries but seems too complicate for something I think should be a basic routine of an OS.

What is supposed to be a basic routine of an OS?

Kernels handle interrupt controllers and manage the handling of interrupt services.

Disk device drivers handle disk interrupts, mouse drivers handle mouse interrupts, keyboard drivers handle keyboard interrupts.

But these are at device driver level.

The idea of a kernel is that it isolates you from machine specifics and provides a logical interface with security and separation from other processes.

If you want to write a user level program you have to work within those limitations.