In unix/linux, the system call umask() sets a umask value and returns the old one. So, in order to get the current umask value without changing it, one can do
#include <sys/types.h>
#include <sys/stat.h>
mode_t get_umask()
{
mode_t mask = umask(0);
umask(mask);
return mask;
}
Post a Comment