This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: open() and mode


On Tue, Sep 25, 2001 at 03:08:14PM -0400, Ivan Dobrianov wrote:
> Does anyone know why the following code creates a file with read/write
> permissions, instead of only read permissions?

If I am not completely wrong, you must set the umask *before*
creating/opening the file. Setting it afterwards does not influence the
permissions of the file just created.

>    int fd = open ("delme.txt", openflag, mode);
> 
>    printf("fd = %d\n", fd);
>    mode_t mask = umask(0);
>    umask(mask);
>    printf("umask = %d\n", mask);

Bye
Jerry

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]