shithub: scc

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