Date: Mon, 27 Aug 2001 21:13:28 -0600 (MDT) From: FreeBSD <freebsd@XtremeDev.com> To: <freebsd-questions@FreeBSD.ORG> Subject: open() in FreeBSD? Message-ID: <20010827210707.G43076-100000@Amber.XtremeDev.com>
next in thread | raw e-mail | index | archive | help
Hello, I have the following test program:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int main()
{
int fd = open("blah", O_WRONLY|O_CREAT);
close(fd);
return EXIT_SUCCESS;
}
When I compiled this and run it, ls -l blah gives me:
---------x 1 freebsd freebsd - 0 Aug 27 20:46 blah*
Looking through man 2 umask, the default umask is 022. Yet the file
created by open() gives me a mask of 001? In the shell I checked the
umask, and it indeed is at 022. If the default umask is 022, why does
leaving out the third argument to open() not follow chmod/umask as implied
by the man 2 open?
"open requires a third argument mode_t mode, and the file is created
with mode mode as described in chmod(2) and modified by the process'
umask value (see umask(2))." - man 2 open
In this case it wasn't modified by the process' umask value (as it is set
to 022 and verified). fopen() works fine. Can anyone shed some light on
this subject? I'm sure I'm missing something simple. Or atleast clear up
the man page on what's default and what's not.
Thanks in advance.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010827210707.G43076-100000>
