I have changed 'alarm' to 'setitimer' which counts only the time while the program is running, which I think is what you want