小编Eri*_*icB的帖子

fflush() 总是返回 0 但将 errno 设置为 11(资源暂时不可用)

每当我调用该vasprintf()函数errno时,该函数都会设置为 11(资源暂时不可用)。但是,似乎一切正常。为了更好地理解错误的来源,我vasprintf()在 uclibc 中找到了一个实现并将其放入我的程序中。我发现 isfflush()设置errno为 11。但是,所有迹象都表明代码运行正常。例如,来自的返回值fflush()0。文件关闭后,的sizeopen_memstream()会正确更新。输出缓冲区已正确更新。我还在output()无限循环中调用了该函数以查看是否有任何内存泄漏,但在几千个循环中我没有看到内存增加。

如果文件被关闭并写入数据,是否真的有错误需要解决?

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>

void output(int type, const char *fmt, ...)
{
    FILE *f;
    size_t size;
    int rv = -1;
    int fclose_return = 5;
    int fflush_return = 5;
    va_list ap;
    char *output_str_no_prefix = NULL;
    va_start(ap, fmt);
//  vasprintf(&output_str_no_prefix, fmt, ap);

    if ((f = open_memstream(&output_str_no_prefix, &size)) != NULL) …
Run Code Online (Sandbox Code Playgroud)

c uclibc fflush

1
推荐指数
1
解决办法
113
查看次数

标签 统计

c ×1

fflush ×1

uclibc ×1