I am having a really hard time understanding how umask works.
How is something that is 666 masked with 001 still 666 ?
A umask value of
001 says that it is preventing the creation of files with other executable permissions. (Actually not preventing the creation, as preventing the executable-permissions).
666 mode in an
open statement only permits user+group+other for read and write permissions. So the umask has no effect on that.
However umask does not affect chmod.