version 1.27, 2019/10/12 18:32:22 |
version 1.28, 2020/02/27 00:24:40 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
/* $OpenBSD: sftp.c,v 1.195 2019/10/02 00:42:30 djm Exp $ */ |
/* $OpenBSD: sftp.c,v 1.197 2020/01/23 07:10:22 dtucker Exp $ */ |
/* |
/* |
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
* |
* |
Line 204 static const struct CMD cmds[] = { |
|
Line 204 static const struct CMD cmds[] = { |
|
__dead static void |
__dead static void |
killchild(int signo) |
killchild(int signo) |
{ |
{ |
if (sshpid > 1) { |
pid_t pid; |
kill(sshpid, SIGTERM); |
|
waitpid(sshpid, NULL, 0); |
pid = sshpid; |
|
if (pid > 1) { |
|
kill(pid, SIGTERM); |
|
waitpid(pid, NULL, 0); |
} |
} |
|
|
_exit(1); |
_exit(1); |
Line 2252 interactive_loop(struct sftp_conn *conn, |
|
Line 2255 interactive_loop(struct sftp_conn *conn, |
|
const char *line; |
const char *line; |
int count = 0; |
int count = 0; |
|
|
signal(SIGINT, SIG_IGN); |
ssh_signal(SIGINT, SIG_IGN); |
|
|
if (el == NULL) { |
if (el == NULL) { |
if (interactive) |
if (interactive) |
Line 2279 interactive_loop(struct sftp_conn *conn, |
|
Line 2282 interactive_loop(struct sftp_conn *conn, |
|
|
|
/* Handle user interrupts gracefully during commands */ |
/* Handle user interrupts gracefully during commands */ |
interrupted = 0; |
interrupted = 0; |
signal(SIGINT, cmd_interrupt); |
ssh_signal(SIGINT, cmd_interrupt); |
|
|
err = parse_dispatch_command(conn, cmd, &remote_path, |
err = parse_dispatch_command(conn, cmd, &remote_path, |
startdir, batchmode, !interactive && el == NULL); |
startdir, batchmode, !interactive && el == NULL); |
if (err != 0) |
if (err != 0) |
break; |
break; |
} |
} |
signal(SIGCHLD, SIG_DFL); |
ssh_signal(SIGCHLD, SIG_DFL); |
free(remote_path); |
free(remote_path); |
free(startdir); |
free(startdir); |
free(conn); |
free(conn); |
Line 2330 connect_to_server(const char *path, char |
|
Line 2333 connect_to_server(const char *path, char |
|
* kill it too. Contrawise, since sftp sends SIGTERMs to the |
* kill it too. Contrawise, since sftp sends SIGTERMs to the |
* underlying ssh, it must *not* ignore that signal. |
* underlying ssh, it must *not* ignore that signal. |
*/ |
*/ |
signal(SIGINT, SIG_IGN); |
ssh_signal(SIGINT, SIG_IGN); |
signal(SIGTERM, SIG_DFL); |
ssh_signal(SIGTERM, SIG_DFL); |
execvp(path, args); |
execvp(path, args); |
fprintf(stderr, "exec: %s: %s\n", path, strerror(errno)); |
fprintf(stderr, "exec: %s: %s\n", path, strerror(errno)); |
_exit(1); |
_exit(1); |
} |
} |
|
|
signal(SIGTERM, killchild); |
ssh_signal(SIGTERM, killchild); |
signal(SIGINT, killchild); |
ssh_signal(SIGINT, killchild); |
signal(SIGHUP, killchild); |
ssh_signal(SIGHUP, killchild); |
signal(SIGTSTP, suspchild); |
ssh_signal(SIGTSTP, suspchild); |
signal(SIGTTIN, suspchild); |
ssh_signal(SIGTTIN, suspchild); |
signal(SIGTTOU, suspchild); |
ssh_signal(SIGTTOU, suspchild); |
signal(SIGCHLD, sigchld_handler); |
ssh_signal(SIGCHLD, sigchld_handler); |
close(c_in); |
close(c_in); |
close(c_out); |
close(c_out); |
} |
} |