Skip to content

Commit

Permalink
options/linux: set window size in openpty
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectrodeYT committed Oct 8, 2023
1 parent 0c33cfb commit aa1bc42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions options/linux/generic/pty-stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
int openpty(int *mfd, int *sfd, char *name, const struct termios *ios, const struct winsize *win) {
__ensure(!ios);

if (win) {
mlibc::infoLogger() << "mlibc: openpty ignores win argument" << frg::endlog;
}

int ptmx_fd;
if(int e = mlibc::sys_open("/dev/ptmx", O_RDWR | O_NOCTTY, 0, &ptmx_fd); e) {
errno = e;
Expand All @@ -38,6 +34,13 @@ int openpty(int *mfd, int *sfd, char *name, const struct termios *ios, const str
goto fail;
}

if(win) {
if(int ioctl_e, e = mlibc::sys_ioctl(ptmx_fd, TIOCSWINSZ, (void*)win, &ioctl_e); e || ioctl_e) {
errno = e;
goto fail;
}
}

*mfd = ptmx_fd;
*sfd = pts_fd;
return 0;
Expand Down
1 change: 1 addition & 0 deletions options/linux/include/mlibc/linux-sysdeps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ int sys_open(const char *pathname, int flags, mode_t mode, int *fd);
int sys_close(int fd);
int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read);
int sys_write(int fd, const void *buf, size_t count, ssize_t *bytes_written);
int sys_ioctl(int fd, unsigned long request, void *arg, int *result);

[[gnu::weak]] int sys_dup2(int fd, int flags, int newfd);
[[gnu::weak]] int sys_fork(pid_t *child);
Expand Down

0 comments on commit aa1bc42

Please sign in to comment.