1
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
void main()
{
    umask(0000);
    creat("a.txt",666);
}

My expected output is, the file created with the name "a.txt" with the permission as "rwrwrw". But, the output is as follows.

Output:

$ ls -l a.txt 
--w--wx-wT 1 mohanraj mohanraj 0 Sep 11 19:04 a.txt
$

The umask is set to 0. So, I expected the file is created with the default file permission with 666. But, it gives some other output. So, How umask internally worked. And How do I get the expected result.

4

2 に答える 2