set file permission after using open function call using umask

66 Views Asked by At

I need to have a file with 666 permission. So, I tried the following with umask and ended up with different permission.

umask(111);
int fd = open(".sample", O_CREAT | O_RDWR, S_IRWXU|S_IRWXG|S_IRWXO);

-rw--w----  Sep  2 13:19 .sample

I was expecting 666.

Did I use umask in a wrong way? Can someone please help me.

0

There are 0 best solutions below