From 80a429d20a345f222a4151d8f162fd8542244bb5 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 8 Nov 2001 17:49:52 +0000 Subject: [PATCH] * select.cc: Set errno using set_sig_errno() throughout. * signal.cc (signal): Always set SA_RESTART flag. * syscalls.cc (_read): Revert previous patch. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/select.cc | 18 +++++++++--------- winsup/cygwin/signal.cc | 3 +++ winsup/cygwin/syscalls.cc | 1 - 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 12a6578e8..8e5170f19 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2001-11-08 Corinna Vinschen + + * select.cc: Set errno using set_sig_errno() throughout. + * signal.cc (signal): Always set SA_RESTART flag. + * syscalls.cc (_read): Revert previous patch. + 2001-11-08 Corinna Vinschen * select.cc (fhandler_tty_slave::ready_for_read): Return 0 on EBADF. diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 663997446..d3d64eda8 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -89,7 +89,7 @@ typedef long fd_mask; if (cygheap->fdtab.not_open ((s)->fd)) \ { \ (s)->saw_error = true; \ - set_errno (EBADF); \ + set_sig_errno (EBADF); \ return -1; \ } \ @@ -238,7 +238,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, { if (m > MAXIMUM_WAIT_OBJECTS) { - set_errno (EINVAL); + set_sig_errno (EINVAL); return -1; } if (!s->startup (s, this)) @@ -780,7 +780,7 @@ fhandler_tty_slave::ready_for_read (int fd, DWORD howlong) HANDLE w4[2]; if (cygheap->fdtab.not_open (fd)) { - set_errno (EBADF); + set_sig_errno (EBADF); return 0; } if (get_readahead_valid ()) @@ -793,17 +793,17 @@ fhandler_tty_slave::ready_for_read (int fd, DWORD howlong) switch (WaitForMultipleObjects (2, w4, FALSE, howlong)) { case WAIT_OBJECT_0: - set_errno (EINTR); + set_sig_errno (EINTR); return 0; case WAIT_OBJECT_0 + 1: return 1; case WAIT_FAILED: select_printf ("wait failed %E"); - set_errno (EINVAL); /* FIXME: correct errno? */ + set_sig_errno (EINVAL); /* FIXME: correct errno? */ return 0; default: if (!howlong) - set_errno (EAGAIN); + set_sig_errno (EAGAIN); return 0; } } @@ -1089,7 +1089,7 @@ fhandler_base::ready_for_read (int fd, DWORD howlong) if (fd >= 0 && cygheap->fdtab.not_open (fd)) { - set_errno (EBADF); + set_sig_errno (EBADF); avail = 0; break; } @@ -1097,13 +1097,13 @@ fhandler_base::ready_for_read (int fd, DWORD howlong) if (howlong != INFINITE) { if (!avail) - set_errno (EAGAIN); + set_sig_errno (EAGAIN); break; } if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0) { - set_errno (EINTR); + set_sig_errno (EINTR); avail = 0; break; } diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 70671b884..652348302 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -56,6 +56,9 @@ signal (int sig, _sig_func_ptr func) prev = myself->getsig (sig).sa_handler; myself->getsig (sig).sa_handler = func; myself->getsig (sig).sa_mask = 0; + /* SA_RESTART is set to maintain BSD compatible signal behaviour by default. + This is also compatible to the behaviour of signal(2) in Linux. */ + myself->getsig (sig).sa_flags |= SA_RESTART; set_sigcatchers (prev, func); syscall_printf ("%p = signal (%d, %p)", prev, sig, func); diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index fc069ca73..3b2104d7f 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -314,7 +314,6 @@ _read (int fd, void *ptr, size_t len) debug_printf ("non-interruptible read\n"); else if (!cfd->ready_for_read (fd, wait)) { - set_sig_errno (get_errno ()); res = -1; goto out; }