KHTTP_FCGI_GETFD(3)
π KHTTP_FCGI_GETFD(3) π
okay bestie, this one is from the Library Functions Manual and it's giving βtiny getter function with big async energyβ β¨
πΈ NAME πΈ
khttp_fcgi_getfd β get the FastCGI control socket π«Ά
π LIBRARY π
library βlibkcgiβ β yes, that libkcgi π
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>
int
khttp_fcgi_getfd(const struct kfcgi *fcgi);
π¦ DESCRIPTION π¦
okay so khttp_fcgi_getfd() gets the control socket used for handling FastCGI processes π. Use it for polling purposes only in asynchronous applications β that's its whole lane. If you manipulate the returned socket descriptor in any other way, the results are undefined π, so like... don't.
The returned descriptor is only valid after khttp_fcgi_init(3) and prior to khttp_fcgi_free(3) β. That window, bestie, that's the window.
π EXAMPLES π
The example below starts an application in FastCGI or regular CGI mode depending upon the environment π§:
int
main(void)
{
struct pollfd pfd;
struct kreq req;
struct kfcgi *fcgi;
enum kcgi_err er;
int rc;
er = khttp_fcgi_init(&fcgi, NULL, 0, NULL, 0, 0);
if (er != KCGI_OK)
errx(1, "khttp_fcgi_init: %s", kcgi_strerror(er));
pfd.events = POLLIN;
pfd.fd = khttp_fcgi_getfd(fcgi);
/* Poll on other sockets here... */
while ((rc = poll(&pfd, 1, INFTIM)) != -1) {
er = khttp_fcgi_parse(fcgi, &req);
if (er != KCGI_OK)
err(1, "khttp_fcgi_parse: %s", kcgi_strerror(er));
if (KCGI_EXIT == er) {
khttp_free(&req);
break;
}
/* Do something. */
khttp_free(&req);
}
khttp_fcgi_free(fcgi);
if (rc == -1)
err(1, "poll");
return 0;
}
π SEE ALSO π
kcgi(3) β go read it, bestie π
π AUTHORS π
Written by Kristaps Dzonsons <kristaps@bsd.lv>. β iconic β¨
xoxo, from Debian, dated $Mdocdate$, on the KHTTP_FCGI_GETFD(3) page ππ«Ά
π¦ where this page comes from
- alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms