[comp.bugs.sys5] KPL & SSUN signal

gwyn@brl-smoke.UUCP (02/05/87)

The November 1986 UNIX System Support & Update News Call # 235493
and the January 1987 UNIX System V Known Problem List Problem ID 947
both give an incorrect description of the change made to the type
returned by signal() in SVR3.0.  This function returns (void *()),
not (void *) as reported in the AT&T bug notes.  The mention of the
fact that previous C compilers do not support (void *) is totally
irrelevant.

Here's what is actually going on.  Due to the very nature of user
signal handler functions, they have no place to return a value to,
so their return type is properly (void).  However, older UNIX C
compilers did not have a (void) data type; functions that didn't
return values were then conventionally left to default to (int)
return type.  Consequently, the only way to describe the return
value of signal() was as (int *()).  With the introduction of
(void), it became possible to properly declare signal handler
functions, so the proper return type for signal(), (void *()),
could now be expressed.  However, due mostly to inertia the change
was not made in many places (notably <signal.h>) for a long time.

X3J11 made a serious effort to clean up the types of library
function parameters and return values.  The last two significant
type botches to be straightened out were for signal() and onexit()
(later renamed atexit()).  IEEE P1003 eventually went along with
the change, and AT&T finally picked it up for the SVID and SVR3.0.

Note that on most architectures the type mismatch between an "old"
signal handler type declaration and the "new" correct one has no
practical effect other than generation of warning messages by the
compiler and "lint".  However, since C is currently able to express
the correct type, one should use it.

People using compilers derived from the 4.2BSD compiler may have
a problem, since that version (lifted from an internal AT&T version
around the time of USG 3.0) doesn't fully understand functions that
return void; in particular it can't handle pointers to such
functions.  This makes it hard to use the correct signal() type!
Such compiler bugs should be fixed (as this one was for 4.3BSD).

karl@haddock.UUCP (02/09/87)

In article <5593@brl-smoke.ARPA> gwyn@brl-smoke.ARPA (Doug Gwyn) writes:
>[The signal() function] returns (void *()), not (void *) as reported in the
>AT&T bug notes.

No, it returns (void (*)()).

gwyn@brl-smoke.UUCP (02/11/87)

In article <372@haddock.UUCP> karl@haddock.ISC.COM.UUCP (Karl Heuer) writes:
>No, it returns (void (*)()).

Quite right; sorry.