gensio_close(3)
π NAME π
gensio_close, gensio_close_s, gensio_disable, gensio_free β the girlies that stop and/or free a gensio that's open π«Ά
β¨ SYNOPSIS β¨
First things first bestie, you gotta pull in the header:
#include <gensio/gensio.h>
typedef void (*gensio_done)(struct gensio *io, void *close_data);
int gensio_close(struct gensio *io, gensio_done close_done,
void *close_data);
int gensio_close_s(struct gensio *io);
void gensio_disable(struct gensio *io);
void gensio_free(struct gensio *io);
πΈ DESCRIPTION πΈ
gensio_close β the gentle shutdown π
Okay so gensio_close closes an open gensio. But here's the tea: the close operation is not complete until close_done() gets called. No cap. It shuts down internal file descriptors and all that, but it does not free the gensio β she's still there, just not doing anything.
If your gensio is a connecting one, you can generally re-open it. Slay, recycling. β»οΈ
Now for the spicy part: if you gensio_close before an open done is reported, the results are undefined β mostly like, whether the open done even gets called at all. And if the open done does get called, it will be called before the close done. Order matters, bestie.
gensio_close_s β the synchronous one π³
gensio_close_s is like gensio_close, but it blocks until the operation is complete.
π¨ BE VERY CAREFUL WITH THIS FUNCTION. Do not call it from a callback, because it waits until all operations on the gensio are done, and they won't be done until the callback returns. If you do this, you will deadlock. That's it, that's the whole warning. Don't do it. π
gensio_disable β the nuclear-ish option π
gensio_disable disables operation of the gensio so that closing will not result in any data being transmitted.
π₯ THIS IS FOR EXTREMELY LIMITED USE.
It will not close file descriptors nor disable I/O, necessarily β but it will put the gensio stack into a state where freeing will not result in any transmission of data to the other end.
You MUST be in a state where no callbacks are running or can run. Not "should", must. π
Why does this even exist? It's primarily to allow a close of something like an SSL connection after a fork. Because if you didn't have this, the normal close in the one fork would shut down the SSL connection for the other fork too. Rude. π See gensio(5) for details on forking β iykyk.
gensio_free β the real goodbye π¦
gensio_free frees the data associated with the gensio. And if it's open? Well, the gensio gets closed. Two birds, one iconique function.
But wait β if you call gensio_free after gensio_close but before the close_done callback is called, then whether close_done gets called is undefined. So like, maybe? Maybe not? Nobody knows. β¨
π RETURN VALUES π
0on success π- a gensio error on failure π
π SEE ALSO π
Ok that's the whole page bestie, you're basically a gensio expert now π
β¨ This was gensio_close(3) from the Library Functions Manual, dated 27 Feb 2019. Go forth and close responsibly π«Ά
π¦ where this page comes from
- alpine 3.22: gensio-doc 2.8.14-r0 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- alpine 3.23: gensio-doc 2.8.14-r0 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- alpine 3.24: gensio-doc 2.8.14-r0 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- arch rolling: gensio 3.0.4-1 Β· GPL
- debian bookworm: libgensio-dev 2.6.2-4 Β· GPL-2.0-only
- debian trixie: libgensio-dev 2.8.13-7 Β· GPL-2.0-only
- epel 9: libgensio-devel 2.8.15-1.el9 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 2.8.15-5.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 2.8.15-5.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 3.0.4-1.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 43: libgensio-devel 3.0.4-1.fc43 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.2-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.2-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.4-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- fedora 44: libgensio-devel 3.0.4-1.fc44 Β· GPL-2.0-only AND LGPL-2.1-only AND Apache-2.0
- nixos 26.05: gensio 3.0.2
- nixpkgs unstable: gensio 3.0.2
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- opensuse-leap 16.0: gensio-devel 2.8.2-bp160.1.13 Β· Apache-2.0 AND GPL-2.0-only AND LGPL-2.1-only
- ubuntu jammy: libgensio-dev 2.3.5-1build2 Β· GPL-2.0-only
- ubuntu noble: libgensio-dev 2.8.2-6.1build1 Β· GPL-2.0-only
- ubuntu questing: libgensio-dev 2.8.13-7
- ubuntu resolute: libgensio-dev 3.0.0-1build1 Β· GPL-2.0-only
- ubuntu stonking: libgensio-dev 3.0.0-1ubuntu1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms