Why umask in C program doen't work as expected

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
0
down vote

favorite












I have the following code comes from the apue book:



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

int
main()
S_IWGRP


In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :



$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo


But it should be like this :



$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo


So what's going on? Why the umask in my program doesn't work?







share|improve this question
















  • 1




    Are the files on an NTFS/FAT32 file system?
    – muru
    May 15 at 6:58










  • I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
    – Sut
    May 15 at 7:03










  • Fedora is off-topic here, and the question about the filesystem still applies.
    – muru
    May 15 at 7:03










  • Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
    – Sut
    May 15 at 7:07










  • @Sut whe"re did you move it to? an EXT4 partition?
    – Fabby
    May 17 at 4:32















up vote
0
down vote

favorite












I have the following code comes from the apue book:



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

int
main()
S_IWGRP


In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :



$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo


But it should be like this :



$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo


So what's going on? Why the umask in my program doesn't work?







share|improve this question
















  • 1




    Are the files on an NTFS/FAT32 file system?
    – muru
    May 15 at 6:58










  • I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
    – Sut
    May 15 at 7:03










  • Fedora is off-topic here, and the question about the filesystem still applies.
    – muru
    May 15 at 7:03










  • Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
    – Sut
    May 15 at 7:07










  • @Sut whe"re did you move it to? an EXT4 partition?
    – Fabby
    May 17 at 4:32













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have the following code comes from the apue book:



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

int
main()
S_IWGRP


In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :



$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo


But it should be like this :



$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo


So what's going on? Why the umask in my program doesn't work?







share|improve this question












I have the following code comes from the apue book:



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

int
main()
S_IWGRP


In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :



$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo


But it should be like this :



$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo


So what's going on? Why the umask in my program doesn't work?









share|improve this question











share|improve this question




share|improve this question










asked May 15 at 6:53









Sut

9




9







  • 1




    Are the files on an NTFS/FAT32 file system?
    – muru
    May 15 at 6:58










  • I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
    – Sut
    May 15 at 7:03










  • Fedora is off-topic here, and the question about the filesystem still applies.
    – muru
    May 15 at 7:03










  • Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
    – Sut
    May 15 at 7:07










  • @Sut whe"re did you move it to? an EXT4 partition?
    – Fabby
    May 17 at 4:32













  • 1




    Are the files on an NTFS/FAT32 file system?
    – muru
    May 15 at 6:58










  • I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
    – Sut
    May 15 at 7:03










  • Fedora is off-topic here, and the question about the filesystem still applies.
    – muru
    May 15 at 7:03










  • Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
    – Sut
    May 15 at 7:07










  • @Sut whe"re did you move it to? an EXT4 partition?
    – Fabby
    May 17 at 4:32








1




1




Are the files on an NTFS/FAT32 file system?
– muru
May 15 at 6:58




Are the files on an NTFS/FAT32 file system?
– muru
May 15 at 6:58












I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
– Sut
May 15 at 7:03




I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
– Sut
May 15 at 7:03












Fedora is off-topic here, and the question about the filesystem still applies.
– muru
May 15 at 7:03




Fedora is off-topic here, and the question about the filesystem still applies.
– muru
May 15 at 7:03












Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
– Sut
May 15 at 7:07




Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
– Sut
May 15 at 7:07












@Sut whe"re did you move it to? an EXT4 partition?
– Fabby
May 17 at 4:32





@Sut whe"re did you move it to? an EXT4 partition?
– Fabby
May 17 at 4:32
















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036401%2fwhy-umask-in-c-program-doent-work-as-expected%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036401%2fwhy-umask-in-c-program-doent-work-as-expected%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Which professions warranted travel in Medieval times?

How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

Trouble downloading packages list due to a “Hash sum mismatch” error