zoukankan      html  css  js  c++  java
  • 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 ");
        sleep(15);
        printf("done ");
        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]$ 

  • 相关阅读:
    输入法searchLookUpEditd的使用
    DevExpress GridControl使用方法总结
    DevExpress 控件中GridControl的使用
    MSSQl 事务的使用
    Python class NameError name "xxx" is not defined
    win 10 slmgr.vbs -xpr 无法运行,被豆麦笔记打开解决方法
    git checkout 撤销多个文件,撤销整个文件夹
    Python argparse 模块,参数传递
    Python Enum 枚举 用法汇总
    git branch & checkout fetch 的使用和冲突解决
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3236902.html
Copyright © 2011-2022 走看看