|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-06-02 20:59 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 12 19:00:01 2025 UTC |
Here is correct function : int php_read(int fd, void *buf, int maxlen) { char *t; int m = 0, n = 0; int no_read = 0; errno = 0; t = (char *) buf; while (*t != '\n' && *t != '\r' && *t != '\0' && n < maxlen) { m = read(fd, (void *) t, 1); if (m > 0) { t++; n++; } else if (m == 0) { no_read++; if (no_read > 200) { errno = ECONNRESET; return -1; } } if (errno != 0 && errno != ESPIPE && errno != EAGAIN) { return -1; } errno = 0; } return n; }