linux之unlink函数解析
来源:互联网 发布:php 数组 分组 avg 编辑:程序博客网 时间:2024/05/22 20:29
[lingyun@localhost unlink]$ cat unlink.c
/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: unlink.c
* Description: This file
*
* Version: 1.0.0(08/04/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "08/04/2013 10:37:14 AM"
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
/********************************************************************************
* Description:
* Input Args:
* Output Args:
* Return Value:
********************************************************************************/
int main (void)
{
if(open("tempfile", O_RDWR) < 0)
{
perror("open");
exit(1);
}
if(unlink("tempfile") < 0)
{
perror("unlink");
exit(1);
}
printf("file unlinked\n");
sleep(15);
printf("done\n");
exit(0);
} /* ----- End of main() ----- */
[lingyun@localhost unlink]$ gcc unlink.c
[lingyun@localhost unlink]$ touch tempfile
[lingyun@localhost unlink]$ ./a.out &
[1] 30273
[lingyun@localhost unlink]$ file unlinked
[lingyun@localhost unlink]$ ls tempfile
ls: cannot access tempfile: No such file or directory
[lingyun@localhost unlink]$ done
[1]+ Done ./a.out
[lingyun@localhost unlink]$
/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: unlink.c
* Description: This file
*
* Version: 1.0.0(08/04/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "08/04/2013 10:37:14 AM"
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
/********************************************************************************
* Description:
* Input Args:
* Output Args:
* Return Value:
********************************************************************************/
int main (void)
{
if(open("tempfile", O_RDWR) < 0)
{
perror("open");
exit(1);
}
if(unlink("tempfile") < 0)
{
perror("unlink");
exit(1);
}
printf("file unlinked\n");
sleep(15);
printf("done\n");
exit(0);
} /* ----- End of main() ----- */
[lingyun@localhost unlink]$ gcc unlink.c
[lingyun@localhost unlink]$ touch tempfile
[lingyun@localhost unlink]$ ./a.out &
[1] 30273
[lingyun@localhost unlink]$ file unlinked
[lingyun@localhost unlink]$ ls tempfile
ls: cannot access tempfile: No such file or directory
[lingyun@localhost unlink]$ done
[1]+ Done ./a.out
[lingyun@localhost unlink]$
- linux之unlink函数解析
- link,unlink,rename函数之解析
- unlink remove 函数解析
- linux unlink函数
- Linux系统调用-- unlink函数详解
- Linux系统调用-- unlink函数详解
- Linux系统调用-- unlink函数详解
- Linux系统调用-- unlink函数详解
- linux下unlink函数的使用
- unlink函数
- unlink 函数
- unlink函数
- unlink()函数
- unlink函数
- unlink()函数
- Linux unlink()
- Linux堆溢出漏洞利用之unlink
- linux堆溢出学习之unsafe unlink
- UVA——10090(数论之线性方程)(挑战编程题目)
- c# txt文本转xml文本
- mysql重装
- HelloHTML5World分析
- 上传图像后圈选矩形框,并左右同步
- linux之unlink函数解析
- T-SQL把字符串变表,字符串变数组,字符数组长度
- 点击按钮执行前先弹出确认框
- 【多校练习4签到题】HDU 4642—— Fliping game
- 初识magento
- sre_constants.error: unbalanced parenthesis
- iOS越狱程序开发(3)- Your First Tweak
- PHP isset()与empty()的使用区别详解
- #define宏定义的使用