Commit 76276a99 authored by Niels Möller's avatar Niels Möller
Browse files

*** empty log message ***

Rev: ChangeLog:1.367
Rev: src/client.h:1.40
Rev: src/suspend.c:1.1
Rev: src/suspend.h:1.1
parent 297fa4f6
2001-06-19 Niels Mller <nisse@cuckoo.hack.org>
* src/client_session.c (client_read_stdin): New function, for
installing the escape-char handler on stdin.
(do_client_io): Use client_read_stdin.
(make_client_session_channel): Added argument escape.
* src/client_escape.c: Moved suspend-related code to suspend.c.
* src/client.c (client_escape_info): New function.
(client_options): New option ---escape-char or 'e'.
(make_client_session): Seet up escape char info.
(client_argp_parser): Handle escape-char option. Call
suspend_install_handler.
* src/Makefile.am.in (liblsh_a_SOURCES): Added suspend.c.
* src/unix_interact.c: Moved suspend-related code to suspend.c.
* src/suspend.c, src/suspend.h: New files.
* configure.in: Bumped version to 1.3.2.
2001-06-17 Niels Mller <nisse@cuckoo.hack.org>
* src/rsync/rsync.h: Include <inttypes.h>, not <stdint.h>.
......
......@@ -92,6 +92,7 @@ struct ssh_channel *
make_client_session_channel(struct lsh_fd *in,
struct lsh_fd *out,
struct lsh_fd *err,
struct escape_info *escape,
UINT32 initial_window,
int *exit_status);
......@@ -109,6 +110,9 @@ make_pty_request(struct interact *tty);
(tty object interact)
; -1 means default.
(escape . int)
; For i/o exceptions
(handler object exception_handler)
......
/* suspend.c
*
* Handle process suspend for the client programs.
*
* $Id$ */
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 2001 Niels Mller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "suspend.h"
#include "tty.h"
#include "werror.h"
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
static struct termios original_mode;
static int tty_fd = -1;
/* On SIGTSTP, we restore the tty mode to the origanal.
* On SIGCONT, we restore it, and the stdio fd flags, to what we hade before
* the suspend. */
static void
stop_handler(int signum)
{
struct termios mine;
int need_tty_reset;
int stdin_flags;
int stdout_flags;
int stderr_flags;
assert(signum == SIGTSTP);
stdin_flags = fcntl(STDIN_FILENO, F_GETFL);
stdout_flags = fcntl(STDOUT_FILENO, F_GETFL);
stderr_flags = fcntl(STDERR_FILENO, F_GETFL);
need_tty_reset = (tty_fd > 0) ? tty_getattr(tty_fd, &mine) : 0;
if (need_tty_reset)
tty_setattr(tty_fd, &original_mode);
kill(getpid(), SIGSTOP);
if (need_tty_reset)
tty_setattr(tty_fd, &mine);
if (stdin_flags >= 0)
fcntl(STDIN_FILENO, F_SETFL, stdin_flags);
if (stdout_flags >= 0)
fcntl(STDOUT_FILENO, F_SETFL, stdin_flags);
if (stderr_flags >= 0)
fcntl(STDERR_FILENO, F_SETFL, stdin_flags);
}
void
suspend_install_handler(void)
{
struct sigaction stop;
memset(&stop, 0, sizeof(stop));
stop.sa_handler = stop_handler;
sigemptyset(&stop.sa_mask);
stop.sa_flags = 0;
if (sigaction(SIGTSTP, &stop, NULL) < 0)
werror("Failed to install SIGTSTP handler (errno = %i): %z\n",
errno, STRERROR(errno));
}
void
suspend_handle_tty(int fd)
{
tty_fd = fd;
if (!tty_getattr(fd, &original_mode))
werror("install_suspend_handler: tty_getattr failed (errno = %i): %z\n",
errno, STRERROR(errno));
}
/* A callback that suspends the process. */
static void
do_suspend(struct lsh_callback *self UNUSED)
{
if (kill(getpid(), SIGTSTP) < 0)
werror("do_suspend: kill failed (errno = %i): %z\n",
errno, STRERROR(errno));
}
/* FIXME: Use const? */
struct lsh_callback
suspend_callback = { STATIC_HEADER, do_suspend };
/* suspend.h
*
* Handle process suspend for the client programs.
*
* $Id$ */
/* lsh, an implementation of the ssh protocol
*
* Copyright (C) 2001 Niels Möller
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LSH_SUSPEND_H_INCLUDED
#define LSH_SUSPEND_H_INCLUDED
#include "io.h"
void
suspend_install_handler(void);
void
suspend_handle_tty(int fd);
struct lsh_callback
suspend_callback;
#endif /* LSH_SUSPEND_H_INCLUDED */
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