I've been following a thread on OSS-Security called Security risk of vim swap files. It looks like Vim and Emacs caught a CVE because the editors created temp files in the wrong place with too many file permissions.
I know Posix has a umask function to set the mask, but I don't really see a function to query it. I'm also aware some shells support UMASK, but I did not see it mentioned in the IEEE pages I visited. (Maybe I missed it; also see How to check umask for all users under Linux?).
How can programs query the umask value in a portable way?