Hi all
Suppose I have:
static sig_atomic_t timed_out= 0;
void time_out( int unrequired ){
timed_out= 1;
}
And I successfully call:
signal( SIGFOO, time_out );
If I suspect that SIGFOO may be be delivered soon, is it sufficient to do:
while( ! timed_out )
do_something_ta king_finite_tim e();
Or do I need to do something like:
while( !*(volatile sig_atomic_t*)& timed_out )
How does this change when:
a) I am sure that timed_out is accessed only by this translation unit?
b) A pointer to timed_out may be read from another translation unit?
c) A pointer to timed_out may be written to by another translation unit?
Is it necessary to use sig_atomic_t for this task, or could a non-atomic
type be used, like bool or int?
Thanks
viza
Suppose I have:
static sig_atomic_t timed_out= 0;
void time_out( int unrequired ){
timed_out= 1;
}
And I successfully call:
signal( SIGFOO, time_out );
If I suspect that SIGFOO may be be delivered soon, is it sufficient to do:
while( ! timed_out )
do_something_ta king_finite_tim e();
Or do I need to do something like:
while( !*(volatile sig_atomic_t*)& timed_out )
How does this change when:
a) I am sure that timed_out is accessed only by this translation unit?
b) A pointer to timed_out may be read from another translation unit?
c) A pointer to timed_out may be written to by another translation unit?
Is it necessary to use sig_atomic_t for this task, or could a non-atomic
type be used, like bool or int?
Thanks
viza
Comment