#!/usr/bin/perl ########################################### # Interrupt a busy process in intervals # Mike Schilli, 2002 (m@perlmeister.com) ########################################### use warnings; use strict; use Inline "C"; $SIG{VTALRM} = sub { print "Just checking!\n"; }; interval_set(10, 0, 0, 250000); while(1) { # Crunch, crunch! } __END__ __C__ #include /* ##################################### */ void interval_set( long secs, long usecs, long isecs, long iusecs ){ /* ##################################### */ struct itimerval timer; timer.it_value.tv_sec = secs; timer.it_value.tv_usec = usecs; timer.it_interval.tv_sec = isecs; timer.it_interval.tv_usec = iusecs; setitimer (ITIMER_VIRTUAL, &timer, NULL); }