[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SIGPOLL on Darwin

From: Bruno Haible
Subject: Re: SIGPOLL on Darwin
Date: Tue, 31 Jan 2012 22:18:36 +0100
User-agent: KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; )

Reuben Thomas wrote:
> (SIGPOLL is mandated by POSIX).

This is not true. Look at
In the table, SIGPOLL is marked with OB and XSR.
  - [OB] means obsolescent.
  - [XSR] means XSI STREAMS. This is an optional part of POSIX that only
    few systems implement, namely glibc, SVR4 based systems, and AIX.
    BSD systems don't implement XSI STREAMS.

> I'm writing Lua bindings for POSIX APIs

What can signals like SIGPOLL bring you in this use-case? Given that
you can't evaluate Lua code from within a signal handler (a consequence
of Lua's interpreter using malloc()/realloc(), and malloc()/realloc() not
being safe to be called from a signal handler), what can the user do with
a C binding that offers signals?

> Also, gnulib does not define _POSIX_C_SOURCE on Darwin, which is
> necessary in order to get some POSIX features.

It is better *not* to fiddle with _POSIX_C_SOURCE, because on many
systems _POSIX_C_SOURCE has the effect of hiding many platform specific

For example, on glibc systems <features.h> contains:

/* If nothing (other than _GNU_SOURCE) is defined,
   define _BSD_SOURCE and _SVID_SOURCE.  */
#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
     !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
     !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
     !defined _BSD_SOURCE && !defined _SVID_SOURCE)
# define _BSD_SOURCE    1
# define _SVID_SOURCE   1

On MacOS X systems <sys/cdefs.h> contains:

 * STRICT       Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the
 *              available APIs to exactly the set of APIs defined by the
 *              corresponding standard, based on the value defined.

Similarly, on OpenBSD, the presence of _POSIX_C_SOURCE hides some functions:

#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    (_XOPEN_VERSION - 0) >= 500
ssize_t  pread(int, void *, size_t, off_t);
ssize_t  pwrite(int, const void *, size_t, off_t);

> Is there anything to be done in gnulib

No. SIGPOLL is definitely not in the scope of the common, widely used
Unix APIs that gnulib cares about.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]