Reputation: 71
I have a C program , running on a Linux system, that can take up to a hour to complete. I need to monitor it's behavior at various times, from other processes, for example perf. The program prints out various diagnostics so if I watch it I'll know exactly when to run my observability tools.
But I don't want to spend time watching the program waiting for it to get to the proper places where I need to take action, since I have other things to do. So it seemed like a solution to my problem was to have the program make sounds when it gets to places where I need to take action. Having it ring the bell would do the job. However I could very easily miss a single ring of the bell, so I would like to make the bell ring 30 or 40 times in succession.
The problem is that if I write the following loop:
for ( i=0; i<40; i++)
{
printf("\a");
}
the bell only rings once. Even if I manually inline the printf()s, and insert statements between each one, the bell still only rings once.
Maybe the optimizer optimizes away the additional beeps; I didn't check the generated assembly to see if this is the case. But this is doubtful, because if I change the printf()s to
printf("----------------------- \a \n");
I get as many lines of dashes, as I ask for, but still only one bell beep.
So, is there a way to get 40 beeps in succession?
Upvotes: 1
Views: 112