Skip to content
On this page

Linux临时文件


标签:linux/文件  

临时文件:

  1. 如何不冲突
  2. 及时销毁

tmpnam()

为临时文件创建一个名字。

c
#include <stdio.h>
char *tmpnam(char *s);

多线程不安全。

tmpfile()

创建一个临时文件,二进制的文件 ( w + b 权限 )。

c
#include <stdio.h>
FILE *tmpfile(void);

匿名文件,没有名称,fclose 后或者进程中断后就不存在,但只打开不关闭 ulimit 会达到上限。

Reference

https://www.bilibili.com/video/BV1wd4y137fd/?p=12

Last updated: