SOCKET_ACCEPT4_SETCLOSEONEXEC(3)
β¨ socket_accept4_setcloseonexec β the "accept it AND make it close-on-exec" glow-up β¨
okay bestie, settle in, we're in the Library Functions Manual and this one is a lil function from libowfat that does exactly what its very long name says π
πΈ NAME πΈ
socket_accept4_setcloseonexec β accept an IPv4 TCP connection on a socket and set it to close on exec
π¦ SYNTAX π¦
#include <libowfat/socket.h>
int socket_accept4_setcloseonexec(int s,char ip[4],uint16 *port);
π DESCRIPTION π
so here's the tea, bestie: this is functionally equivalent to calling socket_accept4 and then calling io_closeonexec on the socket that comes back. literally the same outcome, no cap.
but however β and this is the iconic part β it may save you a syscall or two, and in the process it avoids a race condition. like, she's doing the same thing but she's doing it smarter. main character energy fr fr π₯
π EXAMPLE π
#include <libowfat/socket.h>
int s;
char ip[4];
uint16 p;
s = socket_tcp4();
socket_bind4(s,ip,p);
socket_listen(s,16);
socket_accept4_setcloseonexec(s,ip,&p);
look at her go π setting up a socket, binding, listening, then accepting and setting close-on-exec in one lil move. obsessed.
π SEE ALSO π
socket_accept4(3)socket_connected(3)socket_accept6_setcloseonexec(3)socket_accept4_makenonblocking_setcloseonexec(3)
π«Ά and that's the whole page, bestie! this was the Library Functions Manual entry for socket_acc...closeonexec(3) β that's the name you'll see in the header and down at the bottom in the footer, iykyk. go forth and accept your connections responsibly π
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms