Commit 7fd991ee authored by Niels Möller's avatar Niels Möller
Browse files

(spawn_process): Call io_set_type, if stdin

is a pty.
(do_eof): Removed the pty ^D hack,a s it's now taken care of by
close_fd_write.

* src/io.c (io_set_type): New function.
(close_fd_nicely): Call close_fd_write, for handling the
write-related work.
(close_fd_write): If the fd is a pty, write a EOF (^D) character.

* src/io.h (lsh_fd): New attribute TYPE.

Rev: ChangeLog:1.512
Rev: src/io.c:1.167
Rev: src/io.h:1.90
Rev: src/server_session.c:1.85
parent e6c9aae6
2002-06-18 Niels Mller <nisse@cuckoo.hack.org>
* src/server_session.c (spawn_process): Call io_set_type, if stdin
is a pty.
(do_eof): Removed the pty ^D hack,a s it's now taken care of by
close_fd_write.
2002-06-17 Niels Mller <nisse@cuckoo.hack.org>
* src/io.c (io_set_type): New function.
(close_fd_nicely): Call close_fd_write, for handling the
write-related work.
(close_fd_write): If the fd is a pty, write a EOF (^D) character.
* src/io.h (lsh_fd): New attribute TYPE.
2002-06-05 Niels Mller <nisse@cuckoo.hack.org>
* configure.ac: Bumped version to 1.4.1. New option
......
......@@ -1324,6 +1324,7 @@ make_lsh_fd(int fd, const char *label,
self->fd = fd;
self->label = label;
self->type = 0;
self->e = make_exception_handler(do_exc_io_handler, e, HANDLER_CONTEXT);
......@@ -1339,6 +1340,14 @@ make_lsh_fd(int fd, const char *label,
return self;
}
void
io_set_type(struct lsh_fd *fd, enum io_type type)
{
trace("io_set_type: fd %i, type %i\n",
fd->fd, type);
fd->type = type;
}
unsigned
io_nfiles(void)
{
......@@ -1756,7 +1765,7 @@ close_fd(struct lsh_fd *fd)
* buffer fails. */
if (fd->write_buffer)
fd->write_buffer->closed = 1;
if (fd->close_callback)
LSH_CALLBACK(fd->close_callback);
......@@ -1784,21 +1793,17 @@ close_fd_nicely(struct lsh_fd *fd)
trace("io.c: close_fd_nicely called on fd %i: %z\n",
fd->fd, fd->label);
fd->read = NULL;
/* Stop reading */
fd->read = NULL;
lsh_oop_cancel_read_fd(fd);
if (fd->write_buffer)
{
/* Mark the write_buffer as closed */
fd->write_buffer->closed = 1;
if (!fd->write_buffer->empty)
return;
}
/* There's no data buffered for write. */
close_fd(fd);
if (fd->write_buffer)
/* Close after currently buffered data is written out. */
close_fd_write(fd);
else
/* There's no data buffered for write. */
close_fd(fd);
}
/* Stop reading, but if the fd has a write callback, keep it open. */
......@@ -1822,6 +1827,19 @@ close_fd_write(struct lsh_fd *fd)
{
/* Mark the write_buffer as closed */
fd->write_buffer->closed = 1;
if (fd->type == IO_PTY)
{
debug("Writing ^D to pty.\n");
/* Is there any better way to signal EOF on a pty? This is
* what emacs does. */
A_WRITE(&fd->write_buffer->super,
ssh_format("%lc", /* C-d */ 4));
/* No need to repeat this. */
fd->type = 0;
}
if (fd->write_buffer->empty)
{
if (!fd->read)
......
......@@ -39,6 +39,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
enum io_type { IO_PTY = 1 };
#define GABA_DECLARE
#include "io.h.x"
......@@ -73,7 +74,9 @@
(vars
(next object lsh_fd)
(fd . int)
; PTY:s need special treatment, as sutdown doesn't work.
(type . "enum io_type")
; For debugging purposes
(label . "const char *")
......@@ -287,6 +290,8 @@ void io_init_fd(int fd);
struct lsh_fd *
make_lsh_fd(int fd, const char *label,
struct exception_handler *e);
void
io_set_type(struct lsh_fd *fd, enum io_type type);
struct exception_handler *
make_exc_finish_read_handler(struct lsh_fd *fd,
......
......@@ -67,8 +67,9 @@
; Resource to kill when the channel is closed.
(process object lsh_process)
; pty
; An allocated but not yet used pty
(pty object pty_info)
; value of the TERM environment variable
(term string)
......@@ -132,15 +133,7 @@ do_eof(struct ssh_channel *channel)
CAST(server_session, session, channel);
trace("server_session.c: do_eof\n");
if (session->pty)
/* Is there any better way to signal EOF on a pty? This is what
* emacs does. */
/* FIXME: This should be handled specially by close_fd_write, so
* that we can ignore EPIPE errors. */
A_WRITE(&session->in->write_buffer->super,
ssh_format("%lc", /* C-d */ 4));
close_fd_write(session->in);
}
......@@ -166,6 +159,9 @@ make_server_session(UINT32 initial_window,
* is taken care of automatically. */
self->process = NULL;
self->pty = NULL;
self->term = NULL;
self->in = NULL;
self->out = NULL;
......@@ -458,7 +454,10 @@ spawn_process(struct server_session *session,
= io_write(make_lsh_fd(info->in[1], "child stdin",
io_exception_handler),
SSH_MAX_PACKET, NULL);
if (session->pty)
io_set_type(session->in, IO_PTY);
/* Flow control */
session->in->write_buffer->report = &session->super.super;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment