I am creating a file with full permission (777) using the open system call, but when I do ls -l I can see only permission as (755). Could you pleas
umask will return the original value of the mask, so to reset it temporarily you just need to do
#include
#include
mode_t old_mask = umask(0);
...
umask(old_mask);
though it would be perhaps preferable to use fchmod after opening the file - this will avoid the problem of changing process-global state:
fd = open("test", O_CREAT | O_RDWR | O_APPEND, 0777);
if (fd < 0) { ... }
int rv = fchmod(fd, 0777);
if (rv < 0) { /* fchmod errored */ }