[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]$