I am wondering if there is anything at the assembly level in x86-64 that allows you to sleep/wait, such that no instructions are run until the wait is done. I have seen the WAIT and PAUSE instructions, but I'm not sure they're related.
I would imagine it like this:
start:
wait 123, oninterrupt ; 123 milliseconds
; then it will go here after that time
oninterrupt:
; ctrl-c pressed, now exit
Likewise, I am wondering if there are event hooks/handlers in x86. So if someone presses CTRL+C, there will be an interrupt event sent to assembly somewhere and you can run your "exit" code on that. I would imagine an event handler could be written in assembly x86 like this:
start:
int 10, onctrlc ; register handler for made up event
; ... more instructions evaluate right after
onctrlc:
; control+c pressed, now exit
But I'm not just thinking for CTRL+C, but for any event (which I don't know that much about). I saw this tiny event loop lib in C, not sure if any of that can be done with a simple assembly instruction. Things like keyboard events, socket events, file events, other events I'm not sure what they would be.
Also, this would be run as a regular user on an operating system. But knowing how to do it for privileged users would be nice to know. And also not concerned with how you can do it with linux C functions or syscalls, I understand how to do it like that so far.