From: Ben Myles Date: 2005-10-07T09:20:47+09:00 Subject: how to run some c code for every real and forked ruby process I have some C code (shown below) which I want executed every time ruby runs (it spawns a monitoring script that monitors the ruby process). I tried placing the code in main.c, and this works fine at first glance. However, if I fork something from within ruby the newly forked process doesn't get monitored (which is also why I can't just write a simple bash ruby wrapper). Could someone point me to a function in the ruby source where I can insert the code so that it would be run once for both real processes and forked children? I'm no C programmer, so I'm a bit out of my league here ;-) int monitor_pid = getpid(); char monitor_buffer[100]; sprintf(monitor_buffer, "/usr/local/bin/monitor %i &", monitor_pid); system(monitor_buffer); Thanks! Ben