Embedded Programmer
Embedded Programmer

Reputation: 641

variable atomic operation in signal handler linux c

I have declare long long variable and update and checking the value in main routine. In signal handler, i am checking its value and updating value. Suppose if i make the operation atomic, during its update in main routine, i got signal handler, in signal handler if that variable is already in process of update, then signal handler is not updating the status. When control again come back, i lost the signal handler routine functionality. How can i avoid this?

Regards.
Learner

Upvotes: 0

Views: 418

Answers (1)

Ran Eldan
Ran Eldan

Reputation: 1350

Use sigaction() instead of signal().

Upvotes: 2

Related Questions