I can reproduce the behavior locally, but it is not Zig-caused.
$ zig build-exe createfileperms.zig
$ strace ./createfileperms
openat(AT_FDCWD, "sample.txt", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3
So 0666
is being passed to the openat
syscall by Zig.
umask
seems to be the answer.
$ umask
0002
$ umask 0
$ zig run createfileperms.zig
$ ls -la sample.txt
-rw-rw-rw- 1 ryan ryan 0 Jul 12 05:15 sample.txt