shithub: scc

ref: 66b39b58b8cda3e3c3a86c23401cad0e670a3432
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;
	}
}