aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-11-08 17:49:52 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-11-08 17:49:52 +0000
commit80a429d20a345f222a4151d8f162fd8542244bb5 (patch)
tree26cdb5481b1fc093d2aaff3d598398c9687915c1 /winsup/cygwin
parent036fd823dcf4cf161304a894258477d175b1c3f0 (diff)
downloadnewlib-80a429d20a345f222a4151d8f162fd8542244bb5.zip
newlib-80a429d20a345f222a4151d8f162fd8542244bb5.tar.gz
newlib-80a429d20a345f222a4151d8f162fd8542244bb5.tar.bz2
* select.cc: Set errno using set_sig_errno() throughout.
* signal.cc (signal): Always set SA_RESTART flag. * syscalls.cc (_read): Revert previous patch.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/select.cc18
-rw-r--r--winsup/cygwin/signal.cc3
-rw-r--r--winsup/cygwin/syscalls.cc1
4 files changed, 18 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 12a6578..8e5170f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,11 @@
2001-11-08 Corinna Vinschen <corinna@vinschen.de>
+ * 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 <corinna@vinschen.de>
+
* select.cc (fhandler_tty_slave::ready_for_read): Return 0 on EBADF.
* syscalls.cc (_read): If ready_for_read() failed, save errno from
being overwritten by signal handler call.
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 6639974..d3d64ed 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 70671b8..6523483 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 fc069ca..3b2104d 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;
}