feat: adapt to latest CGI protocol

This commit is contained in:
源文雨
2026-01-30 23:09:38 +08:00
parent 728f72e8f6
commit 743dd4f8ef
2 changed files with 17 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.6...4.1.1)
project(C302 C)
SET(CMAKE_BUILD_TYPE "Release")

16
c302.c
View File

@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <sys/uio.h>
#include <time.h>
#include "c302.h"
@@ -31,3 +32,18 @@ int main(int argc, char **argv) {
};
return writev(1, (const struct iovec *)&iov, 4) != len+sizeof(uint32_t);
}
static void __attribute__((destructor)) defer_close_fp() {
fflush(stdout);
char buf[256];
fd_set rfds;
struct timeval tv;
int ret;
FD_ZERO(&rfds);
FD_SET(0, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
if (select(1, &rfds, NULL, NULL, &tv) > 0 && FD_ISSET(0, &rfds)) {
read(0, buf, sizeof(buf));
}
}