X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmisc%2Fpty.c;h=a0577147a4c2b6ef251ede679d56354b406fbb4c;hb=e3e7189c11d909199155327fd6a93dcc6b68c7b3;hp=6ca33e3169b66fc1874343b21802bf17d788305e;hpb=750b738e53f799443fcfcd3a0751318c072a022f;p=musl diff --git a/src/misc/pty.c b/src/misc/pty.c index 6ca33e31..a0577147 100644 --- a/src/misc/pty.c +++ b/src/misc/pty.c @@ -2,11 +2,14 @@ #include #include #include -#include "libc.h" +#include +#include "syscall.h" int posix_openpt(int flags) { - return open("/dev/ptmx", flags); + int r = open("/dev/ptmx", flags); + if (r < 0 && errno == ENOSPC) errno = EAGAIN; + return r; } int grantpt(int fd) @@ -22,10 +25,11 @@ int unlockpt(int fd) int __ptsname_r(int fd, char *buf, size_t len) { - int pty; + int pty, err; if (!buf) len = 0; - return -( ioctl (fd, TIOCGPTN, &pty) < 0 - || snprintf(buf, len, "/dev/pts/%d", pty) >= len ); + if ((err = __syscall(SYS_ioctl, fd, TIOCGPTN, &pty))) return -err; + if (snprintf(buf, len, "/dev/pts/%d", pty) >= len) return ERANGE; + return 0; } weak_alias(__ptsname_r, ptsname_r);