shithub: scc

ref: 994751d39485e086ef623f202fb1b84729fd5d19
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;
	}
}