f



sig_atomic_t: from signal handler: set or access?

Hi,

seeing in SUSv3:

1)
==={{{ functions/sigaction.html
     If the signal occurs other than as the result of calling abort(),
     kill(), or raise(), the behavior is undefined if the signal handler
     calls any function in the standard library other than one of the
     functions listed in the table above or refers to any object with
     static storage duration other than by assigning a value to a static
     storage duration variable of type volatile sig_atomic_t.
     Furthermore, if such a call fails, the value of errno is
     unspecified.
===}}}

Here, signal handler is allowed only to *set* variable of sig_atomic_t type.

2)
==={{{ basedefs/signal.h.html
   sig_atomic_t
          Possibly volatile-qualified integer type of an object that can
          be accessed as an atomic entity, even in the presence of
          asynchronous interrupts.
===}}}

Here, *access* is allowed (which means not only write, but read also).
What variant is true?
Or reading is prohibited for signal handler, but allowed for "normal" code?


-netch-
0
netch (13)
6/30/2003 6:45:05 AM
comp.unix.programmer 10848 articles. 0 followers. kokososo56 (350) is leader. Post Follow

1 Replies
1161 Views

Similar Articles

[PageSpeed] 34

On Mon, 30 Jun 2003 09:45:05 +0300, Valentin Nechayev 
<netch@segfault.kiev.ua> wrote:

> Hi,
>
> seeing in SUSv3:
>
> 1)
> ==={{{ functions/sigaction.html
> If the signal occurs other than as the result of calling abort(),
> kill(), or raise(), the behavior is undefined if the signal handler
> calls any function in the standard library other than one of the
> functions listed in the table above or refers to any object with
> static storage duration other than by assigning a value to a static
> storage duration variable of type volatile sig_atomic_t.
> Furthermore, if such a call fails, the value of errno is
> unspecified.
> ===}}}
>
> Here, signal handler is allowed only to *set* variable of sig_atomic_t 
> type.
>
> 2)
> ==={{{ basedefs/signal.h.html
> sig_atomic_t
> Possibly volatile-qualified integer type of an object that can
> be accessed as an atomic entity, even in the presence of
> asynchronous interrupts.
> ===}}}
>
> Here, *access* is allowed (which means not only write, but read also).
> What variant is true?
> Or reading is prohibited for signal handler, but allowed for "normal" 
> code?
>
>
> -netch-
>

I think the wording is rough. In addition to the problem you mention, the 
restriction to kill applies only to kills from the same process. Kills from 
another process are asynchronous.

--Marc
0
Marc
7/1/2003 3:02:48 AM
Reply: