* select.cc: Set errno using set_sig_errno() throughout.
* signal.cc (signal): Always set SA_RESTART flag. * syscalls.cc (_read): Revert previous patch.
This commit is contained in:
parent
036fd823dc
commit
80a429d20a
|
@ -1,3 +1,9 @@
|
||||||
|
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>
|
2001-11-08 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* select.cc (fhandler_tty_slave::ready_for_read): Return 0 on EBADF.
|
* select.cc (fhandler_tty_slave::ready_for_read): Return 0 on EBADF.
|
||||||
|
|
|
@ -89,7 +89,7 @@ typedef long fd_mask;
|
||||||
if (cygheap->fdtab.not_open ((s)->fd)) \
|
if (cygheap->fdtab.not_open ((s)->fd)) \
|
||||||
{ \
|
{ \
|
||||||
(s)->saw_error = true; \
|
(s)->saw_error = true; \
|
||||||
set_errno (EBADF); \
|
set_sig_errno (EBADF); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||||
{
|
{
|
||||||
if (m > MAXIMUM_WAIT_OBJECTS)
|
if (m > MAXIMUM_WAIT_OBJECTS)
|
||||||
{
|
{
|
||||||
set_errno (EINVAL);
|
set_sig_errno (EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!s->startup (s, this))
|
if (!s->startup (s, this))
|
||||||
|
@ -780,7 +780,7 @@ fhandler_tty_slave::ready_for_read (int fd, DWORD howlong)
|
||||||
HANDLE w4[2];
|
HANDLE w4[2];
|
||||||
if (cygheap->fdtab.not_open (fd))
|
if (cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_sig_errno (EBADF);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (get_readahead_valid ())
|
if (get_readahead_valid ())
|
||||||
|
@ -793,17 +793,17 @@ fhandler_tty_slave::ready_for_read (int fd, DWORD howlong)
|
||||||
switch (WaitForMultipleObjects (2, w4, FALSE, howlong))
|
switch (WaitForMultipleObjects (2, w4, FALSE, howlong))
|
||||||
{
|
{
|
||||||
case WAIT_OBJECT_0:
|
case WAIT_OBJECT_0:
|
||||||
set_errno (EINTR);
|
set_sig_errno (EINTR);
|
||||||
return 0;
|
return 0;
|
||||||
case WAIT_OBJECT_0 + 1:
|
case WAIT_OBJECT_0 + 1:
|
||||||
return 1;
|
return 1;
|
||||||
case WAIT_FAILED:
|
case WAIT_FAILED:
|
||||||
select_printf ("wait failed %E");
|
select_printf ("wait failed %E");
|
||||||
set_errno (EINVAL); /* FIXME: correct errno? */
|
set_sig_errno (EINVAL); /* FIXME: correct errno? */
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
if (!howlong)
|
if (!howlong)
|
||||||
set_errno (EAGAIN);
|
set_sig_errno (EAGAIN);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1089,7 +1089,7 @@ fhandler_base::ready_for_read (int fd, DWORD howlong)
|
||||||
|
|
||||||
if (fd >= 0 && cygheap->fdtab.not_open (fd))
|
if (fd >= 0 && cygheap->fdtab.not_open (fd))
|
||||||
{
|
{
|
||||||
set_errno (EBADF);
|
set_sig_errno (EBADF);
|
||||||
avail = 0;
|
avail = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1097,13 +1097,13 @@ fhandler_base::ready_for_read (int fd, DWORD howlong)
|
||||||
if (howlong != INFINITE)
|
if (howlong != INFINITE)
|
||||||
{
|
{
|
||||||
if (!avail)
|
if (!avail)
|
||||||
set_errno (EAGAIN);
|
set_sig_errno (EAGAIN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0)
|
if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
set_errno (EINTR);
|
set_sig_errno (EINTR);
|
||||||
avail = 0;
|
avail = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,9 @@ signal (int sig, _sig_func_ptr func)
|
||||||
prev = myself->getsig (sig).sa_handler;
|
prev = myself->getsig (sig).sa_handler;
|
||||||
myself->getsig (sig).sa_handler = func;
|
myself->getsig (sig).sa_handler = func;
|
||||||
myself->getsig (sig).sa_mask = 0;
|
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);
|
set_sigcatchers (prev, func);
|
||||||
|
|
||||||
syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
|
syscall_printf ("%p = signal (%d, %p)", prev, sig, func);
|
||||||
|
|
|
@ -314,7 +314,6 @@ _read (int fd, void *ptr, size_t len)
|
||||||
debug_printf ("non-interruptible read\n");
|
debug_printf ("non-interruptible read\n");
|
||||||
else if (!cfd->ready_for_read (fd, wait))
|
else if (!cfd->ready_for_read (fd, wait))
|
||||||
{
|
{
|
||||||
set_sig_errno (get_errno ());
|
|
||||||
res = -1;
|
res = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue