1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:28:12 +00:00

Add basic PTY support.

For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
This commit is contained in:
Andreas Kling 2019-01-15 06:30:19 +01:00
parent ecb4ab0943
commit 2f74c2f430
21 changed files with 287 additions and 10 deletions

View file

@ -5,8 +5,10 @@
#include <string.h>
#include <alloca.h>
#include <assert.h>
#include <errno.h>
#include <AK/Assertions.h>
#include <AK/Types.h>
#include <Kernel/Syscall.h>
extern "C" {
@ -215,6 +217,19 @@ long atol(const char* str)
return atoi(str);
}
static char ptsname_buf[32];
char* ptsname(int fd)
{
if (ptsname_r(fd, ptsname_buf, sizeof(ptsname_buf)) < 0)
return nullptr;
return ptsname_buf;
}
int ptsname_r(int fd, char* buffer, size_t size)
{
int rc = syscall(SC_ptsname_r, fd, buffer, size);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
static unsigned long s_next_rand = 1;