[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. 比较全面的gdb调试命令 (转载)

    转自http://blog.csdn.net/dadalan/article/details/3758025 用GDB调试程序 GDB是一个强大的命令行调试工具.大家知道命令行的强大就是在于,其可以形 ...

  2. JavaScript框架设计 第14章 动画引擎

    easing-js <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...

  3. ♫【Underscore.js】

    Underscore.js Underscore.js 1.5.2 中文文档 Underscore 是一个JavaScript实用库,提供了类似Prototype.js (或 Ruby)的一些功能,但 ...

  4. POJ 2112 Optimal Milking(Floyd+多重匹配+二分枚举)

    题意:有K台挤奶机,C头奶牛,每个挤奶机每天只能为M头奶牛服务,下面给的K+C的矩阵,是形容相互之间的距离,求出来走最远的那头奶牛要走多远   输入数据: 第一行三个数 K, C, M  接下来是   ...

  5. (转载)php数组删除元素各种方法总结

    (转载)http://www.111cn.net/phper/php/46865.htm 有很多朋友都不知道怎么把数组中元素给删除,下面我来总结各种数组删除元素方法给各位,有需要了解的朋友可进入参考. ...

  6. Python操作Excel_输出所有内容(包含中文)

    python 2.7.5代码: # coding=utf-8 import sys import xlrd data=xlrd.open_workbook('D:\\menu.xls') table ...

  7. Merge Intervals——LeetCode

    Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,1 ...

  8. linux下挂载另一系统硬盘。

    问题描述: Error mounting /dev/sda5 at /media/wangzheng/办公: Command-line `mount -t "ntfs" -o &q ...

  9. entityframework分布式事务中遇到的 “与基础事务管理器的通信失败”的解决方法

    首先是ef的多数据库操作实现事务的方法 public int AddDifferenceDB(userinfo1 user1, userinfo user) { ; using (var test2D ...

  10. tyvj P1431 [Tyvj Jan]分配任务(最大流)

    P1431 [Tyvj Jan]分配任务 时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述      随着tyvj发展越来越大,管理员的任务越来越重,如何合理的 ...