Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a signal on each page fault

Tags:

c

linux

x86-64

I want to set a signal handler in my application, so that the kernel sends a signal whenever it handles a page fault trap. Ofcourse I can use the SIGSEGV signal handler, but what I'm really interested in is to catch the page faults which occur on copy-on-write. For example after a fork (not followed by exec), the original process will get a page fault if it tries to write to some page. I want to get notified on such page faults. How can I achieve this?

like image 914
pythonic Avatar asked Nov 04 '22 01:11

pythonic


1 Answers

page faults are interrupts handled by do_page_fault()

http://www.stillhq.com/pdfdb/000446/data.pdf

Signals also generate an interrupt. The difference is that the page fault interrupt is vectored to the code. There is an explanation of what the code does. IMO, always generating another interrupt in a an interrupt handler is a bad idea.

Tell us: What are you trying to accomplish? Not how you think it should be done.

like image 187
jim mcnamara Avatar answered Nov 07 '22 21:11

jim mcnamara