xinetd 上的所有程序(我读过)都调用 fflush()。为什么?
例如,Inetd-维基百科
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
const char *fn = argv[1];
FILE *fp = fopen(fn, "a+");
if(fp == NULL)
exit(EXIT_FAILURE);
char str[4096];
//inetd passes its information to us in stdin.
while(fgets(str, sizeof(str), stdin)) {
fputs(str, fp);
fflush(fp);
}
fclose(fp);
return 0;
}