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

/*********************************************************************************

 *      Copyright:  (C) 2013 fulinux<fulinux@sina.com> 

 *                  All rights reserved.

 *

 *       Filename:  umask.c

 *    Description:  This file 

 *                 

 *        Version:  1.0.0(08/02/2013~)

 *         Author:  fulinux <fulinux@sina.com>

 *      ChangeLog:  1, Release initial version on "08/02/2013 07:09:24 PM"

 *                 

 ********************************************************************************/

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <unistd.h>

#include <fcntl.h>

#include <sys/stat.h>

#define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)

int main(void)

{

    umask(0);

    if(creat("hello", RWRWRW) < 0)

    {

        printf("creat error for hello\n");

        exit(1);

    }

    umask(S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);

    if(creat("world", RWRWRW) < 0)

    {

        printf("creat error for world");

        exit(1);

    }

    exit(0);

}

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

~                                                                                                                            

 ~/apue/umask/umask_1/umask.c[+]   CWD: /usr/local/src/lingyun/apue/umask/umask_1   Line: 37/38:12                           

"umask.c" [New] 38L, 1016C written

[lingyun@localhost umask_1]$ gcc umask.c 

[lingyun@localhost umask_1]$ umask

0022

[lingyun@localhost umask_1]$ ./a.out 

[lingyun@localhost umask_1]$ ls -l hello world 

-rw-rw-rw- 1 lingyun trainning 0 Aug  2 19:19 hello

-rw------- 1 lingyun trainning 0 Aug  2 19:19 world

[lingyun@localhost umask_1]$ umask

0022

[lingyun@localhost umask_1]$

linux之umask函数解析的更多相关文章

  1. Linux exec族函数解析

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

  2. linux之unlink函数解析

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

  3. linux之access函数解析

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

  4. linux之ioctl函数解析

    [lingyun@localhost ioctl_1]$ ls ipconfig.c [lingyun@localhost ioctl_1]$ cat ipconfig.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. 【HDOJ】2369 Broken Keyboard

    字符串. #include <cstdio> #include <cstring> ]; ]; int main() { int n, len; int i, j, k, tm ...

  2. phpMyAdmin view_create.php 跨站脚本漏洞

    漏洞名称: phpMyAdmin view_create.php 跨站脚本漏洞 CNNVD编号: CNNVD-201307-066 发布时间: 2013-07-05 更新时间: 2013-07-05 ...

  3. 3 B. Lorry

    题目大意:给你两种物品,每种物品有一个价值和花费,花费只有两种,一种花费为 , 一种花费为2.. 给你一个背包容量为v, 求当前容量下所能达到的最大价值. ====================== ...

  4. 【转】 Android开发之EditText属性详解

    原文网址:http://blog.csdn.net/qq435757399/article/details/7947862 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: ...

  5. 【转】Android:Layout_weight的深刻理解

    原文网址:http://mobile.51cto.com/abased-375428.htm 本文详细介绍了Android布局中Layout_weight的属性,它是用来分配属于空间的一个属性,你可以 ...

  6. WebBrowser控件默认使用IE9,IE10的方法

    1,打开注册表 HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)     SOFTWARE        Microsoft           Internet E ...

  7. 动软代码生成器 可用于生成Entity层,可更改模板 /codesmith 也可以

    动软代码生成器官方下载地址:http://www.maticsoft.com/download.aspx 教程:http://jingyan.baidu.com/article/219f4bf7dfd ...

  8. tomcat中debug启动和start启动的区别

    debug启动tomcat:修改代码不加方法,不加参数,只是单纯的修改方法,不用重启tomcat(热部署). start启动tamcat:修改代码需要重启tomcat.

  9. [ES6] Array.find()

    Convenient method to find one item in an array, avoid writing and  for + if: let arys = [1,,5,,6] ; ...

  10. Android Matrix详解

    Matrix的数学原理 平移变换 旋转变换 缩放变换 错切变换 对称变换 代码验证 Matrix的数学原理 在Android中,如果你用Matrix进行过图像处理,那么一定知道Matrix这个类.An ...