X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Funistd%2Fctermid.c;h=c238905adae25292756d62dfb6401e66a7c700fd;hp=21b44ec8602206c676f94e8394f10a8bf60ff67c;hb=cdf0f53f8ba0e79dedb83c626851597bacec53ca;hpb=0716b10ac8dc167f96969c964974d4094035fed0 diff --git a/src/unistd/ctermid.c b/src/unistd/ctermid.c index 21b44ec8..c238905a 100644 --- a/src/unistd/ctermid.c +++ b/src/unistd/ctermid.c @@ -4,6 +4,7 @@ #include #include #include +#include "syscall.h" char *ctermid(char *s) { @@ -13,11 +14,11 @@ char *ctermid(char *s) if (!s2) s2 = malloc(L_ctermid); s = s2; } - fd = open("/dev/tty", O_WRONLY | O_NOCTTY); + 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, ""); - close(fd); + __syscall(SYS_close, fd); return s; }