An invocation of raise(SIGABRT), that is, of a synchronous signal, produces
random behaviour in Cygwin 3.5.5: Sometimes it succeeds, sometimes it fails
with error ENOSYS. In previous releases of Cygwin and in all other operating
systems, it always succeeds.

How to reproduce:
Find test-sigaction.c attached.
Compile it and run it 10 times:
$ x86_64-pc-cygwin-gcc -O2 -Wall test-sigaction.c \
  && ./a && ./a && ./a && ./a && ./a && ./a && ./a && ./a && ./a && ./a
ret = -1, errno = 88
ret = -1, errno = 88
ret = 0, errno = 0
ret = -1, errno = 88
ret = -1, errno = 88
ret = -1, errno = 88
ret = -1, errno = 88
ret = -1, errno = 88
ret = -1, errno = 88
ret = 0, errno = 0

This unit test is part of Gnulib. Really, it is a pity that none of the
Cygwin maintainers is running the Gnulib tests before making a new Cygwin
release.

Bruno
#include <signal.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

int volatile test_exit_status = EXIT_SUCCESS;

#define ASSERT(expr) \
  do                                                                         \
    {                                                                        \
      if (!(expr))                                                           \
        {                                                                    \
          fprintf (stderr, "%s:%d: assertion '%s' failed\n",          \
                   __FILE__, __LINE__, #expr);                               \
          fflush (stderr);                                            \
          if (1)                                         \
            {                                                                \
              test_exit_status = EXIT_FAILURE;                               \
            }                                                                \
          else                                                               \
            abort ();                                                        \
        }                                                                    \
    }                                                                        \
  while (0)

static void
handler (int sig)
{
}

int
main (void)
{
  struct sigaction sa;
  sa.sa_handler = handler;

  sa.sa_flags = 0;
  ASSERT (sigemptyset (&sa.sa_mask) == 0);
  ASSERT (sigaction (SIGABRT, &sa, NULL) == 0);
  int ret = raise (SIGABRT);
  //fprintf (stderr, "ret = %d\n", ret); fflush(stderr);
  fprintf (stderr, "ret = %d, errno = %d\n", ret, errno); fflush(stderr);
  //ASSERT (ret == 0);

  return test_exit_status;
}
-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to