libssh2_sftp_close_handle(3)
β¨ libssh2_sftp_close_handle(3) β¨
okay bestie, gather round, we're closing file handles today and honestly? it's giving closure π this one lives in the libssh2 manual and it's the glow-up your SFTP session needs when you're done with it π
π NAME π
libssh2_sftp_close_handle β close filehandle π«Ά
πΈ SYNOPSIS πΈ
#include <libssh2.h>
#include <libssh2_sftp.h>
int
libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle);
int
libssh2_sftp_close(LIBSSH2_SFTP_HANDLE *handle);
int
libssh2_sftp_closedir(LIBSSH2_SFTP_HANDLE *handle);
π¦ DESCRIPTION π¦
handle β the SFTP File Handle, aka the little token you got handed back from libssh2_sftp_open_ex(3) or libssh2_sftp_opendir(3) (and psst, that last one is a macro π).
So what are we doing here? We're closing an active LIBSSH2_SFTP_HANDLE. And here's the iconic part: because files and directories share the same underlying storage mechanism, these methods are literally interchangeable, no cap. libssh2_sftp_close(3) and libssh2_sftp_closedir(3) are both macros for libssh2_sftp_close_handle(3). Same vibe, same function, three names. main character energy fr fr β¨
π₯ RETURN VALUE π₯
- Returns
0on success, or a negative number on failure. π - It returns
LIBSSH2_ERROR_EAGAINwhen it would otherwise block.
okay important: LIBSSH2_ERROR_EAGAIN is a negative number, yes, but it is not really a failure per se. It's just the function saying "not yet bestie, try again later" π don't panic, it's not a real L.
π ERRORS π
LIBSSH2_ERROR_ALLOCβ an internal memory allocation call failed. the malloc said no πLIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket. the socket is not picking up the phone π΅LIBSSH2_ERROR_SOCKET_TIMEOUTβLIBSSH2_ERROR_SFTP_PROTOCOLβ an invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server. server said something unhinged and we're not entertaining it π
π SEE ALSO π
and that's the whole page bestie, you ate that π go close some handles responsibly, hydrate, and remember: three names, one function, zero drama β¨
libssh2 0.15 Β· 1 Jun 2007 β yeah this page is vintage, it's been iconic since 2007 and it still slays π mwah, bye π«Ά
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms