X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/74aca06df856c5518daf31d2b7a00cc3d798fcaf..e50f98bce64b2e3012c2cc6c39b5c21df3acd700:/unix/pty.c diff --git a/unix/pty.c b/unix/pty.c index eed8ecf7..7f46f1aa 100644 --- a/unix/pty.c +++ b/unix/pty.c @@ -84,6 +84,7 @@ static int pty_exit_code; static struct utmp utmp_entry; #endif char **pty_argv; +int use_pty_argv = TRUE; static void pty_close(void); @@ -484,8 +485,8 @@ static void pty_uxsel_setup(void) * Also places the canonical host name into `realhost'. It must be * freed by the caller. */ -static char *pty_init(void *frontend, void **backend_handle, Config *cfg, - char *host, int port, char **realhost, int nodelay) +static const char *pty_init(void *frontend, void **backend_handle, Config *cfg, + char *host, int port, char **realhost, int nodelay) { int slavefd; pid_t pid, pgrp; @@ -516,9 +517,10 @@ static char *pty_init(void *frontend, void **backend_handle, Config *cfg, * Stamp utmp (that is, tell the utmp helper process to do so), * or not. */ - if (!cfg->stamp_utmp) + if (!cfg->stamp_utmp) { close(pty_utmp_helper_pipe); /* just let the child process die */ - else { + pty_utmp_helper_pipe = -1; + } else { char *location = get_x_display(pty_frontend); int len = strlen(location)+1, pos = 0; /* +1 to include NUL */ while (pos < len) { @@ -526,6 +528,7 @@ static char *pty_init(void *frontend, void **backend_handle, Config *cfg, if (ret < 0) { perror("pterm: writing to utmp helper process"); close(pty_utmp_helper_pipe); /* arrgh, just give up */ + pty_utmp_helper_pipe = -1; break; } pos += ret; @@ -622,21 +625,23 @@ static char *pty_init(void *frontend, void **backend_handle, Config *cfg, return NULL; } -/* - * Stub routine (we don't have any need to reconfigure this backend). - */ static void pty_reconfig(void *handle, Config *cfg) { + /* + * We don't have much need to reconfigure this backend, but + * unfortunately we do need to pick up the setting of Close On + * Exit so we know whether to give a `terminated' message. + */ + pty_cfg = *cfg; /* structure copy */ } /* - * Stub routine (never called in pterm + * Stub routine (never called in pterm). */ static void pty_free(void *handle) { } - /* * Called to send data down the pty. */ @@ -663,7 +668,10 @@ static void pty_close(void) close(pty_master_fd); pty_master_fd = -1; } - close(pty_utmp_helper_pipe); /* this causes utmp to be cleaned up */ + if (pty_utmp_helper_pipe >= 0) { + close(pty_utmp_helper_pipe); /* this causes utmp to be cleaned up */ + pty_utmp_helper_pipe = -1; + } } /* @@ -703,6 +711,21 @@ static void pty_special(void *handle, Telnet_Special code) return; } +/* + * Return a list of the special codes that make sense in this + * protocol. + */ +static const struct telnet_special *pty_get_specials(void *handle) +{ + /* + * Hmm. When I get round to having this actually usable, it + * might be quite nice to have the ability to deliver a few + * well chosen signals to the child process - SIGINT, SIGTERM, + * SIGKILL at least. + */ + return NULL; +} + static Socket pty_socket(void *handle) { return NULL; /* shouldn't ever be needed */ @@ -749,6 +772,7 @@ Backend pty_backend = { pty_sendbuffer, pty_size, pty_special, + pty_get_specials, pty_socket, pty_exitcode, pty_sendok,