linux file creation and umask()

I have a program which writes to a log file. Ofcourse this log file and folder has to be created, my program has to run as root so it always create the folder with rw------- permission and it can't be read and write as a normal user. I don't want this, all users should be able to have read and write permission.

my search online led me to umask(000); however it only works on the file and NOT on the folder. The folder that gets created has only rw permission for root and none for all others while the file has the umask permission I set.

anyone have any idea why this is?


I would try using chmod() from the <sys/stat.h> library which "[...] uses the specified permission bits and ignores the file creation mask.", see here for more information.

#include <sys/stat.h> 
#include <stdio.h>

int main(void) {
  if(chmod("test", 0777) != 0)
    printf("Error while setting permissions on directory.");

  return 1;

Need Your Help

SELECT box: On IE item is added to OptGroup instead of root. FF ok

javascript html dom

I've got a behaviour a bit strange with Select Box and OptGroup:

Watir-Webdriver for Chrome and IE - getting nil error when automating text field input

watir watir-webdriver selenium-chromedriver

I'm using Watir-Webdriver. The script works for me on Firefox, however on Google and IE it breaks right once I enter in data into the modal. I also noticed for IEDriver that inputting text into a t...