summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 848e0e44f..d0896169b 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -355,12 +355,6 @@ _read (int fd, void *ptr, size_t len)
extern "C" ssize_t
_write (int fd, const void *ptr, size_t len)
{
- if (len == 0)
- return 0;
-
- if (__check_invalid_read_ptr_errno (ptr, len))
- return -1;
-
int res = -1;
sigframe thisframe (mainthread);
@@ -368,6 +362,16 @@ _write (int fd, const void *ptr, size_t len)
if (cfd < 0)
goto done;
+ /* No further action required for len == 0 */
+ if (len == 0)
+ {
+ res = 0;
+ goto done;
+ }
+
+ if (len && __check_invalid_read_ptr_errno (ptr, len))
+ goto done;
+
/* Could block, so let user know we at least got here. */
if (fd == 1 || fd == 2)
paranoid_printf ("write (%d, %p, %d)", fd, ptr, len);