summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/stdio/__stdio.c6
-rw-r--r--src/stdio/_stdio.h3
-rw-r--r--src/unistd/ctermid.c8
3 files changed, 11 insertions, 6 deletions
diff --git a/src/stdio/__stdio.c b/src/stdio/__stdio.c
index 2360020f..7170ee63 100644
--- a/src/stdio/__stdio.c
+++ b/src/stdio/__stdio.c
@@ -1,6 +1,10 @@
#include "_stdio.h"
-struct __stdio __stdio;
+struct __stdio __stdio =
+{
+ { { 0 } },
+ "/dev/tty",
+};
/*
STDC(0)
diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h
index 43db57a0..f82edaa0 100644
--- a/src/stdio/_stdio.h
+++ b/src/stdio/_stdio.h
@@ -7,7 +7,7 @@
#ifdef _POSIX_C_SOURCE
#include <sys/types.h>
#else
-#include "../sys/types/pid_t.c"
+#include "sys/types/pid_t.c"
#endif
struct __FILE {
@@ -56,6 +56,7 @@ int __scanf(struct io_options * restrict, const char * restrict, va_list);
struct __stdio {
struct __FILE FILES[FOPEN_MAX];
+ char ctermid[L_ctermid + 1];
};
extern struct __stdio __stdio;
diff --git a/src/unistd/ctermid.c b/src/unistd/ctermid.c
index 32a47b64..122bed8a 100644
--- a/src/unistd/ctermid.c
+++ b/src/unistd/ctermid.c
@@ -2,16 +2,16 @@
#include "sys/types.h"
#include <unistd.h>
#include "stdio.h"
+#include "stdio/_stdio.h"
#include "string.h"
char * ctermid(char * s)
{
- static char termid[L_ctermid] = "/dev/tty";
-
+ /* TODO: return the empty string if there is no controlling terminal */
if (s == NULL) {
- s = termid;
+ s = __stdio.ctermid;
} else {
- strcpy(s, termid);
+ strcpy(s, __stdio.ctermid);
}
return s;