summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSeekingBlues <seekingblues@gmail.com>2022-06-18 00:30:52 +0800
committerAndreas Kling <kling@serenityos.org>2022-06-18 15:10:13 +0200
commitf34e69a52b272587002e2577a3844a2b5e17711b (patch)
treeb95ead98a3337475a2221323d623a53593a5b2b4 /Userland/Libraries
parent5b1e2cc65c66a9a72be969fa7ce3f86f0fda0f07 (diff)
downloadserenity-f34e69a52b272587002e2577a3844a2b5e17711b.zip
LibC: Add `ctermid`
We simply return "/dev/tty", since it always refers to the controlling terminal of the calling process.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibC/stdio.cpp9
-rw-r--r--Userland/Libraries/LibC/stdio.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp
index dd265a2275..82620c2df8 100644
--- a/Userland/Libraries/LibC/stdio.cpp
+++ b/Userland/Libraries/LibC/stdio.cpp
@@ -1299,6 +1299,15 @@ FILE* tmpfile()
return fdopen(fd, "rw");
}
+// https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctermid.html
+char* ctermid(char* s)
+{
+ static char tty_path[L_ctermid] = "/dev/tty";
+ if (s)
+ return strcpy(s, tty_path);
+ return tty_path;
+}
+
size_t __fpending(FILE* stream)
{
ScopedFileLock lock(stream);
diff --git a/Userland/Libraries/LibC/stdio.h b/Userland/Libraries/LibC/stdio.h
index 96999ae422..4b9a769f87 100644
--- a/Userland/Libraries/LibC/stdio.h
+++ b/Userland/Libraries/LibC/stdio.h
@@ -27,6 +27,7 @@ __BEGIN_DECLS
#define _IOLBF 1
#define _IONBF 2
+#define L_ctermid 9
#define L_tmpnam 256
#define P_tmpdir "/tmp"
@@ -99,5 +100,6 @@ FILE* tmpfile(void);
char* tmpnam(char*);
FILE* popen(char const* command, char const* type);
int pclose(FILE*);
+char* ctermid(char* s);
__END_DECLS