[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函数解析的更多相关文章

  1. Linux exec族函数解析

    背景 在提到 vfork 函数时,我们提到了这个概念.为了更好地学习与运用,我们对exec族函数进行展开. exec函数族 介绍 有时我们希望子进程去执行另外的程序,exec函数族就提供了一个在进程中 ...

  2. linux之access函数解析

    [lingyun@localhost access_1]$ ls access.c 实例一: [lingyun@localhost access_1]$ cat access.c  /******** ...

  3. linux之ioctl函数解析

    [lingyun@localhost ioctl_1]$ ls ipconfig.c [lingyun@localhost ioctl_1]$ cat ipconfig.c  /*********** ...

  4. linux之umask函数解析

    [lingyun@localhost umask_1]$ vim umask.c  + umask.c                                                 ...

  5. linux之utime函数解析

    [lingyun@localhost utime]$ ls hello  utime.c  world [lingyun@localhost utime]$ cat utime.c  /******* ...

  6. linux之chdir函数解析

    [lingyun@localhost chdir]$ ls chdir.c [lingyun@localhost chdir]$ cat chdir.c  /********************* ...

  7. linux之getcwd函数解析

    [lingyun@localhost getcwd]$ cat getcwd.c /********************************************************** ...

  8. linux之stat函数解析

    [lingyun@localhost stat_1]$ vim stat.c  + stat.c                                                     ...

  9. 关于Linux系统basename函数缺陷的思考

    某模块作为前台进程独立运行时,运行命令携带命令行参数:作为某平台下守护进程子进程运行时,需要将命令行参数固化在代码里.类似如下写法: char *argv[] = {"./DslDriver ...

随机推荐

  1. LeetCode Single Number (找不不重复元素)

    题意:给一个序列,序列中只有1个是单个的,其他都是成对出现的.也就是序列中有奇数个元素.要求找出这个元素. 思路:成对出现用异或最好了.两个同样的数一异或就变零,剩下的,就是那个落单的. class ...

  2. 【C#学习笔记】调用C++生成的DLL

    首先用vs2010建立win32项目,选择dll和空项目. 头文件add.h extern "C" __declspec(dllexport) int add(int a,int ...

  3. 《Python CookBook2》 第一章 文本 - 每次处理一个字符 && 字符和字符值之间的转换

    文本 - 总结: 什么是文本Python 中的string 类型是不可变类型.文本,一个字符的矩阵,每一个单独的文本快可以被缩进和组织起来. 基本的文本操作①解析数据并将数据放入程序内部的结构中:②将 ...

  4. 使用calabash测试开源中国Android客户端

    Calabash-android是支持android的UI自动化测试框架,前面已经介绍过<中文Win7下成功安装calabash-android步骤>,这篇博文尝试测试一个真实应用:开源中 ...

  5. qt集成到vs2010

    因为要正式开始学习图形处理相关的知识了,所以要搭建开发平台.我所要用到的平台主要是vs和qt.虽然现在已经出了vs2013了,并且外观看起来特别漂亮,但是我所要用到的qt4版本中,没有对于的qtAdd ...

  6. (三)相遇射线的3D碰撞盒

    序 在2D游戏中,我们知道处理碰撞时,需要设置精灵遮罩图.同样,进入3D,处理碰撞时需要3D模型作为“遮罩图”. 索尼克 飞檐走壁   目的 (1)处理模型间的碰撞问题         (2)获取鼠标 ...

  7. bzoj 2594 [Wc2006]水管局长数据加强版(LCT+最小生成树)

    [深坑勿入] [给个链接] http://blog.csdn.net/popoqqq/article/details/41348549 #include<cstdio> #include& ...

  8. SQL游标遍历数据表

    DECLARE @资产编号 VARCHAR(50) ,@gsid VARCHAR(50) DECLARE test_Cursor CURSOR LOCAL FOR SELECT 资产编号,gsid F ...

  9. IO-同步,异步,阻塞,非阻塞,阅读摘要

    http://www.cnblogs.com/Fly-Wind/p/io.html http://blog.csdn.net/historyasamirror/article/details/5778 ...

  10. hive-mysql安装配置

    默认情况下,hive的元数据信息存储在内置的Derby数据中.Facebook将hive元数据存储在关系数据库 1.安装好mysql ,sudo apt-get install mysql-serve ...