mirror of
https://github.com/libssh2/libssh2.git
synced 2026-10-24 03:48:58 +03:00
`libssh2_channel_get_exit_status()` returns 0 both for a real exit
status of 0 and for a channel that never received an `exit-status`
request. A server that force-closes a session, like OpenSSH under
`ChannelTimeout`, makes a still-running command look like a clean exit
0. Reproduction with the stock `example/ssh2_exec` is in #2515.
This adds `libssh2_channel_has_exit_status()`, returning 1 once the
request arrived, the name you suggested.
The new field sits in `_LIBSSH2_CHANNEL` in `libssh2_priv.h` and callers
only ever hold a pointer, so no ABI change.
`libssh2_channel_get_exit_signal()` already lets a caller see whether
that request arrived by leaving the pointer NULL, exit-status was the
odd one out.
Man page and a `test_exit_status` covering both states are included.
Follow-up to 77bd3c1215
Fixes #2515
Closes #2516
779 B
779 B
c, SPDX-License-Identifier, Title, Section, Source, See-also
| c | SPDX-License-Identifier | Title | Section | Source | See-also | |
|---|---|---|---|---|---|---|
| Copyright (C) The libssh2 project and its contributors. | BSD-3-Clause | libssh2_channel_get_exit_status | 3 | libssh2 |
|
NAME
libssh2_channel_get_exit_status - get the remote exit code
SYNOPSIS
#include <libssh2.h>
int libssh2_channel_get_exit_status(LIBSSH2_CHANNEL *channel)
DESCRIPTION
channel - Closed channel stream to retrieve exit status from.
Returns the exit code raised by the process running on the remote host at the other end of the named channel. Note that the exit status may not be available if the remote end has not yet set its status to closed.
RETURN VALUE
Returns 0 on failure, otherwise the Exit Status reported by remote host