---
name: "gensio_close"
section: "3"
platform: "linux"
package: "gensio"
version: "3.0.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/gensio_close"
---

# gensio\_close(3)

Stop/free a gensio that is open

## NAME

gensio\_close, gensio\_close\_s, gensio\_disable, gensio\_free - Stop/free a gensio that is open

## SYNOPSIS

**#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);

  **gensio\_close** closes an open gensio.  Note that the close operation is not complete until close\_done() is called.  This shuts down internal file descriptors and such, but does not free the gensio.  If the gensio is a connecting one, you can generally re-open it.  If you **gensio\_close** before an open done is reported, the results (primarily whether the open done is called) are undefined.  If the open done is called, it will be called before the close done.

**gensio\_close\_s** is like gensio\_close, but 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.  You will deadlock if you do this.

**gensio\_disable** disables operation of the gensio so that closing will not result in any data being transmitted. **THIS IS FOR EXTREMELY LIMITED USE.** This will not close file descriptors nor disable I/O, necessarily, but 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.  This is primarily to allow a close of something like an SSL connection after a fork.  If you didn't have this, the normal close in the one fork would shut down the SSL connection for the other fork, too.  See [gensio(5)](/gensio/5.md) for details on forking.

**gensio\_free** frees data associated with the gensio.  If it is open, the gensio is closed.  If you call **gensio\_free** after **gensio\_close** before the **close\_done** callback is called, whether **close\_done** is called is undefined.

## RETURN VALUES

Zero is returned on success, or a gensio error on failure.

## SEE ALSO

[gensio\_err(3)](/gensio_err/3.md), [gensio(5)](/gensio/5.md)
