add234(ptys_by_fd, pty);
}
+static Pty new_pty_struct(void)
+{
+ Pty pty = snew(struct pty_tag);
+ pty->conf = NULL;
+ bufchain_init(&pty->output_data);
+ return pty;
+}
+
/*
* Pre-initialisation. This is here to get around the fact that GTK
* doesn't like being run in setuid/setgid programs (probably
int pipefd[2];
#endif
- pty = single_pty = snew(struct pty_tag);
- pty->conf = NULL;
- bufchain_init(&pty->output_data);
+ pty = single_pty = new_pty_struct();
/* set the child signal handler straight away; it needs to be set
* before we ever fork. */
pty = single_pty;
assert(pty->conf == NULL);
} else {
- pty = snew(struct pty_tag);
+ pty = new_pty_struct();
pty->master_fd = pty->slave_fd = -1;
#ifndef OMIT_UTMP
pty_stamped_utmp = FALSE;
if (pty->master_fd < 0)
pty_open_master(pty);
- /*
- * Set the backspace character to be whichever of ^H and ^? is
- * specified by bksp_is_delete.
- */
- {
- struct termios attrs;
- tcgetattr(pty->master_fd, &attrs);
- attrs.c_cc[VERASE] = conf_get_int(conf, CONF_bksp_is_delete)
- ? '\177' : '\010';
- tcsetattr(pty->master_fd, TCSANOW, &attrs);
- }
-
#ifndef OMIT_UTMP
/*
* Stamp utmp (that is, tell the utmp helper process to do so),
}
if (pid == 0) {
+ struct termios attrs;
+
/*
* We are the child.
*/
#endif
pgrp = getpid();
tcsetpgrp(0, pgrp);
+
+ /*
+ * Set up configuration-dependent termios settings on the new
+ * pty. Linux would have let us do this on the pty master
+ * before we forked, but that fails on OS X, so we do it here
+ * instead.
+ */
+ if (tcgetattr(0, &attrs) == 0) {
+ /*
+ * Set the backspace character to be whichever of ^H and
+ * ^? is specified by bksp_is_delete.
+ */
+ attrs.c_cc[VERASE] = conf_get_int(conf, CONF_bksp_is_delete)
+ ? '\177' : '\010';
+
+ /*
+ * Set the IUTF8 bit iff the character set is UTF-8.
+ */
+#ifdef IUTF8
+ if (frontend_is_utf8(frontend))
+ attrs.c_iflag |= IUTF8;
+ else
+ attrs.c_iflag &= ~IUTF8;
+#endif
+
+ tcsetattr(0, TCSANOW, &attrs);
+ }
+
setpgid(pgrp, pgrp);
{
int ptyfd = open(pty->name, O_WRONLY, 0);
del234(ptys_by_pid, pty);
del234(ptys_by_fd, pty);
+ bufchain_clear(&pty->output_data);
+
conf_free(pty->conf);
pty->conf = NULL;
pty_provide_logctx,
pty_unthrottle,
pty_cfg_info,
+ NULL /* test_for_upstream */,
"pty",
-1,
0