1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:17:46 +00:00

Add sys$ttyname_r and ttyname_r() + ttyname().

And print a greeting when sh starts up so we know which TTY we're on.
This commit is contained in:
Andreas Kling 2018-10-30 22:03:02 +01:00
parent 7a85384e47
commit 00c21d1590
12 changed files with 78 additions and 3 deletions

View file

@ -38,6 +38,20 @@ ssize_t write(int fd, const void* buf, size_t count)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int ttyname_r(int fd, char* buffer, size_t size)
{
int rc = Syscall::invoke(Syscall::PosixTtynameR, (dword)fd, (dword)buffer, (dword)size);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
static char ttyname_buf[32];
char* ttyname(int fd)
{
if (ttyname_r(fd, ttyname_buf, sizeof(ttyname_buf)) < 0)
return nullptr;
return ttyname_buf;
}
int close(int fd)
{
int rc = Syscall::invoke(Syscall::PosixClose, fd);

View file

@ -18,6 +18,8 @@ int lstat(const char* path, stat* statbuf);
int sleep(unsigned seconds);
int gethostname(char*, size_t);
ssize_t readlink(const char* path, char* buffer, size_t);
char* ttyname(int fd);
int ttyname_r(int fd, char* buffer, size_t);
#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
#define WTERMSIG(status) ((status) & 0x7f)