#define TERM_CBREAK 1
#define TERM_RAW 2
+#if !defined(TIOCGSIZE) && defined(TIOCGWINSZ)
+# define TIOCGSIZE TIOCGWINSZ
+# define TIOCSSIZE TIOCSWINSZ
+# define ttysize winsize
+# define ts_cols ws_col
+#endif
+
struct script_buf {
int len; /* buffer length (how much read in) */
int off; /* write position (how much already consumed) */
static void script_run(const char *path, char *argv[], char *envp[], int);
static void sigchild(int s);
static void sigwinch(int s);
-static void sync_winsize(int src, int dst);
+static void sync_ttysize(int src, int dst);
static void deliver_signal(pid_t pid, int signo);
/* sudo.c */
if (foreground && !tty_initialized) {
if (term_copy(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE], ttyout)) {
tty_initialized = 1;
- sync_winsize(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE]);
+ sync_ttysize(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE]);
}
}
}
/* Copy terminal attrs from user tty -> pty slave. */
if (term_copy(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE], ttyout)) {
tty_initialized = 1;
- sync_winsize(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE]);
+ sync_ttysize(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE]);
}
/* Start out in raw mode is stdout is a tty. */
}
static void
-sync_winsize(int src, int dst)
+sync_ttysize(int src, int dst)
{
-#ifdef TIOCGWINSZ
- struct winsize win;
+#ifdef TIOCGSIZE
+ struct ttysize tsize;
pid_t pgrp;
- if (ioctl(src, TIOCGWINSZ, &win) == 0) {
- ioctl(dst, TIOCSWINSZ, &win);
+ if (ioctl(src, TIOCGSIZE, &tsize) == 0) {
+ ioctl(dst, TIOCSSIZE, &tsize);
#ifdef TIOCGPGRP
if (ioctl(dst, TIOCGPGRP, &pgrp) == 0)
killpg(pgrp, SIGWINCH);
{
int serrno = errno;
- sync_winsize(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE]);
+ sync_ttysize(script_fds[SFD_USERTTY], script_fds[SFD_SLAVE]);
errno = serrno;
}