4 ms·
I'd keep an int flag, initialized to zero. The sighandler sets the flag. The flag is checked (and reset) on entry to newCoin(). Not exactly pretty, but using
by smcdow 15y ago
I'd keep an int flag, initialized to zero. The sighandler sets the flag. The flag is checked (and reset) on entry to newCoin().
Not exactly pretty, but using signals to trigger to produce reports isn't exactly pretty either.
Unfortunately, signals are often abused in this manner. Not a big deal for such for this small piece of software, but in larger systems this kind of abuse can cause very hard to fix bugs.
- cperciva 15y agoI'd keep an int flag, initialized to zero. If you do, your code is buggy: sig_atomic_t is the only type you can safely use inside and outside a signal handler.
- smcdow 15y agoPlease explain why this would be true for single-threaded applications.
- vonuebelgarten 15y agoBecause your signal handler may get interrupted by another signal.
- smcdow 15y agoSo what? Even then, there will be no concurrency issues in a single threaded application.