X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Funistd%2Fctermid.c;h=1612770af158ce068e2b9a1ecc89c4d910d76edd;hb=2b754a542492f5878608a1130e00021ae02a0e34;hp=c238905adae25292756d62dfb6401e66a7c700fd;hpb=cdf0f53f8ba0e79dedb83c626851597bacec53ca;p=musl diff --git a/src/unistd/ctermid.c b/src/unistd/ctermid.c index c238905a..1612770a 100644 --- a/src/unistd/ctermid.c +++ b/src/unistd/ctermid.c @@ -1,24 +1,7 @@ #include -#include #include -#include -#include -#include -#include "syscall.h" char *ctermid(char *s) { - static char *s2; - int fd; - if (!s) { - if (!s2) s2 = malloc(L_ctermid); - s = s2; - } - fd = open("/dev/tty", O_WRONLY | O_NOCTTY | O_CLOEXEC); - if (fd < 0) - return strcpy(s, ""); - if (ttyname_r(fd, s, L_ctermid)) - strcpy(s, ""); - __syscall(SYS_close, fd); - return s; + return s ? strcpy(s, "/dev/tty") : "/dev/tty"; }