#include <Cocoa/Cocoa.h> #define SECONDS 4 @interface Foo : NSObject { @public unsigned val; } - (void)increment; @end @implementation Foo : NSObject - (void)increment { val++; } @end Foo* gFoo; void signal_handler(int signal) { printf("%d\n", gFoo->val / SECONDS); exit(0); } int main(void) { Foo* foo = [[Foo alloc] init]; gFoo = foo; signal(SIGALRM, signal_handler); alarm(SECONDS); for (;;) { [foo increment]; } return 0; }