[maybe OT] signal( ) standard ?

E

Eric Boutin

Hi ! currently reading C docs, I think I'm reading docs about the stdc lib,
but I'm not shure.. it talks about signals, does *all* OS implement the
signal function, and use it well ? I mean.. I know Unixes do it, but what
about windows ? does it implements all SIG* signal promptly ?

Thanks !

-Eric Boutin
 
I

Irrwahn Grausewitz

Eric Boutin said:
Hi ! currently reading C docs, I think I'm reading docs about the stdc lib,
but I'm not shure.. it talks about signals, does *all* OS implement the
signal function, and use it well ? I mean.. I know Unixes do it, but what
about windows ? does it implements all SIG* signal promptly ?

A conforming C implementation must provide signal handling. However,
signal handling in C has several implementation defined aspects, for
obvious reasons. Here's what the standard says about it:

ISO/IEC 9899:1999 7.14#3+4
The macros defined are [...] and distinct values that are the signal
numbers, each corresponding to the specified condition:
SIGABRT [...]
SIGFPE [...]
SIGILL [...]
SIGINT [...]
SIGSEGV [...]
SIGTERM [...]
An implementation need not generate any of these signals, except as
a result of explicit calls to the raise function. Additional signals
[...] may also be specified by the implementation. The complete set
of signals, their semantics, and their default handling is
implementation-defined; all signal numbers shall be positive.

HTH

Regards
 
J

Jack Klein

Hi ! currently reading C docs, I think I'm reading docs about the stdc lib,
but I'm not shure.. it talks about signals, does *all* OS implement the
signal function, and use it well ? I mean.. I know Unixes do it, but what
about windows ? does it implements all SIG* signal promptly ?

Thanks !

-Eric Boutin

The definition of signals in the C standard places no requirements at
all on the operating system. C defines what happens if signal
handlers are installed and the corresponding identifier is used in a
call to raise(). If a signal handler is invoked any other way, the C
standard does not define the results.

As to what signals are or are not supported by various operating
system, that is not a C language issue. Consult the documentation or
support groups for the operating systems of interest.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
D

Dan Pop

In said:
The definition of signals in the C standard places no requirements at
all on the operating system. C defines what happens if signal
handlers are installed and the corresponding identifier is used in a
call to raise(). If a signal handler is invoked any other way, the C
standard does not define the results.

Bullshit! The C standard specifies what an asynchronously invoked
signal handler is allowed to do without invoking undefined behaviour.

5 If the signal occurs other than as the result of calling the
abort or raise function, the behavior is undefined if the signal
handler refers to any object with static storage duration other
than by assigning a value to an object declared as volatile
sig_atomic_t, or the signal handler calls any function in
the standard library other than the abort function, the _Exit
function, or the signal function with the first argument equal
to the signal number corresponding to the signal that caused
the invocation of the handler. Furthermore, if such a call to
the signal function results in a SIG_ERR return, the value of
errno is indeterminate.

It's only the asynchronous delivery of *certain* signals (SIGFPE, SIGILL,
SIGSEGV) that renders the program's behaviour undefined if the signal
handler ever returns.

What the standard does not guarantee is that a signal handler will be
ever invoked asynchronously.

Dan
 
D

Dan Pop

In said:
Hi ! currently reading C docs, I think I'm reading docs about the stdc lib,
but I'm not shure.. it talks about signals, does *all* OS implement the
signal function, and use it well ? I mean.. I know Unixes do it, but what
about windows ? does it implements all SIG* signal promptly ?

The C language allows perfectly useless implementations of signal(),
i.e. an implementation is not required to be able to invoke any signal
handler asynchronously.

And this is pretty much the case of Windows, except that console
applications can receive the SIGINT signal, but its handling is
performed in a non-standard conforming way (the handler is run in a
separate thread of its own, while the program execution continues).

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top