X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Funistd%2Fctermid.c;h=1612770af158ce068e2b9a1ecc89c4d910d76edd;hb=5f12ffe1239a5e4f8d4e98e2dff4e191a71f4693;hp=21b44ec8602206c676f94e8394f10a8bf60ff67c;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/unistd/ctermid.c b/src/unistd/ctermid.c index 21b44ec8..1612770a 100644 --- a/src/unistd/ctermid.c +++ b/src/unistd/ctermid.c @@ -1,23 +1,7 @@ #include -#include #include -#include -#include -#include 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); - if (fd < 0) - return strcpy(s, ""); - if (ttyname_r(fd, s, L_ctermid)) - strcpy(s, ""); - close(fd); - return s; + return s ? strcpy(s, "/dev/tty") : "/dev/tty"; }