linux之unlink函数解析
[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]$
linux之unlink函数解析的更多相关文章
- Linux exec族函数解析
背景 在提到 vfork 函数时,我们提到了这个概念.为了更好地学习与运用,我们对exec族函数进行展开. exec函数族 介绍 有时我们希望子进程去执行另外的程序,exec函数族就提供了一个在进程中 ...
- linux之access函数解析
[lingyun@localhost access_1]$ ls access.c 实例一: [lingyun@localhost access_1]$ cat access.c /******** ...
- linux之ioctl函数解析
[lingyun@localhost ioctl_1]$ ls ipconfig.c [lingyun@localhost ioctl_1]$ cat ipconfig.c /*********** ...
- linux之umask函数解析
[lingyun@localhost umask_1]$ vim umask.c + umask.c ...
- linux之utime函数解析
[lingyun@localhost utime]$ ls hello utime.c world [lingyun@localhost utime]$ cat utime.c /******* ...
- linux之chdir函数解析
[lingyun@localhost chdir]$ ls chdir.c [lingyun@localhost chdir]$ cat chdir.c /********************* ...
- linux之getcwd函数解析
[lingyun@localhost getcwd]$ cat getcwd.c /********************************************************** ...
- linux之stat函数解析
[lingyun@localhost stat_1]$ vim stat.c + stat.c ...
- 关于Linux系统basename函数缺陷的思考
某模块作为前台进程独立运行时,运行命令携带命令行参数:作为某平台下守护进程子进程运行时,需要将命令行参数固化在代码里.类似如下写法: char *argv[] = {"./DslDriver ...
随机推荐
- ZOJ 2587 Unique Attack (最小割唯一性)
题意 判断一个无向图的割是否唯一 思路 错误思路:一开始想的是判断割边是否都是关键割边,那既然割边两端点能连通S.T点的边是关键边,那么只要遇到有某个边两端点不连通S or T则这条边就不是关键割边( ...
- jquery仿邮箱文本输入框自动加载邮箱后缀
在像百度这样的网站注册时,你会看到输入邮箱会出现自动给用户输入补全主流邮箱.这种对于增加用户体验的小例子已司空见惯.正好看到人家写的这种js功能.还挺不错,使用起来很方便,几乎不用写神呢代码.&quo ...
- SharePoint 2010 列表项事件接收器 ItemAdded 的使用方法
列表项事件处理器是继承于Microsoft.SharePoint.SPItemEventReceiver的类,Microsoft.SharePoint.SPItemEventReceiver类提供了许 ...
- mssql的delete用用到被delete的表的别名
+' delete m from '+@strDBName +'.dbo.m_device as m where not exists ' +' (select 1 from @tmpDevice w ...
- hdu 2473 Junk-Mail Filter(并查集_虚节点)2008 Asia Regional Hangzhou
感觉有些难的题,刚开始就想到了设立虚节点,但是实现总是出错,因为每次设立了虚节点之后,无法将原节点和虚节点分开,导致虚节点根本无意义. 以上纯属废话,可以忽略…… 题意—— 给定n个点(0, 1, 2 ...
- ios游戏开发--cocos2d学习(2)
在第一节中简单介绍了2d项目模板HelloWorld的基础代码,并做了一点小小的改变,像触摸接收.旋转.移动和颜色转变序列CCSequence的使用等等,2d本身封装好了很多方便使用的动作,只需要调用 ...
- 如何将自定义RPM包加入YUM
1 前言 在很多时候进行编译了自己的RPM包,在搭建YUM的时候,希望将自定义的RPM加入到YUM源中,从而出现了下列方法. 2. 将RPM包加入YUM源 2.1 查看目前repodata位置 YUM ...
- mvc JavaScriptResult的用法
一.JavaScriptResult在MVC中的定义的代码片段 C# 代码 复制 public class JavaScriptResult : ActionResult { public o ...
- ctags支持的语言
http://ctags.sourceforge.net/languages.html Languages Supported by Exuberant Ctags: Ant Assembler AS ...
- android - python 自动化测试 移动互联网 - SegmentFault
android - python 自动化测试 移动互联网 - SegmentFault splinter