Just to follow up, this was fairly easy to do with ptrace. I'll attach the small resulting C file below in case anyone is interested, or to seed future Google searches.
View entire thread