version 1.335, 2023/03/07 06:09:14 |
version 1.336, 2023/08/10 23:05:48 |
|
|
{ |
{ |
Channel *c; |
Channel *c; |
int r; |
int r; |
|
char *note = NULL; |
|
|
if ((c = channel_lookup(ssh, s->chanid)) == NULL) |
if ((c = channel_lookup(ssh, s->chanid)) == NULL) |
fatal_f("session %d: no channel %d", s->self, s->chanid); |
fatal_f("session %d: no channel %d", s->self, s->chanid); |
debug_f("session %d channel %d pid %ld", |
|
s->self, s->chanid, (long)s->pid); |
|
|
|
if (WIFEXITED(status)) { |
if (WIFEXITED(status)) { |
channel_request_start(ssh, s->chanid, "exit-status", 0); |
channel_request_start(ssh, s->chanid, "exit-status", 0); |
if ((r = sshpkt_put_u32(ssh, WEXITSTATUS(status))) != 0 || |
if ((r = sshpkt_put_u32(ssh, WEXITSTATUS(status))) != 0 || |
(r = sshpkt_send(ssh)) != 0) |
(r = sshpkt_send(ssh)) != 0) |
sshpkt_fatal(ssh, r, "%s: exit reply", __func__); |
sshpkt_fatal(ssh, r, "%s: exit reply", __func__); |
|
xasprintf(¬e, "exit %d", WEXITSTATUS(status)); |
} else if (WIFSIGNALED(status)) { |
} else if (WIFSIGNALED(status)) { |
channel_request_start(ssh, s->chanid, "exit-signal", 0); |
channel_request_start(ssh, s->chanid, "exit-signal", 0); |
if ((r = sshpkt_put_cstring(ssh, sig2name(WTERMSIG(status)))) != 0 || |
if ((r = sshpkt_put_cstring(ssh, sig2name(WTERMSIG(status)))) != 0 || |
|
|
(r = sshpkt_put_cstring(ssh, "")) != 0 || |
(r = sshpkt_put_cstring(ssh, "")) != 0 || |
(r = sshpkt_send(ssh)) != 0) |
(r = sshpkt_send(ssh)) != 0) |
sshpkt_fatal(ssh, r, "%s: exit reply", __func__); |
sshpkt_fatal(ssh, r, "%s: exit reply", __func__); |
|
xasprintf(¬e, "signal %d%s", WTERMSIG(status), |
|
WCOREDUMP(status) ? " core dumped" : ""); |
} else { |
} else { |
/* Some weird exit cause. Just exit. */ |
/* Some weird exit cause. Just exit. */ |
ssh_packet_disconnect(ssh, "wait returned status %04x.", status); |
ssh_packet_disconnect(ssh, "wait returned status %04x.", |
|
status); |
} |
} |
|
|
|
debug_f("session %d channel %d pid %ld %s", s->self, s->chanid, |
|
(long)s->pid, note == NULL ? "UNKNOWN" : note); |
|
free(note); |
|
|
/* disconnect channel */ |
/* disconnect channel */ |
debug_f("release channel %d", s->chanid); |
debug_f("release channel %d", s->chanid); |