shithub: scc

ref: 560a156341e5bb352194a85c3258406a079697b7
dir: /src/libc/arch/posix/tmpfile.c/

View raw version
#include <stdio.h>

#include "../../syscall.h"

#undef tmpfile

FILE *
tmpfile(void)
{
	char *fname;
	FILE *fp;

	for (;;) {
		if ((fname = tmpnam(NULL)) == NULL)
			return NULL;
		if ((fp = fopen(fname, "wt+")) == NULL)
			continue;
		_unlink(fname);
		return fp;
	}
}