Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:56:22+00:00 2026-06-15T07:56:22+00:00

I want to create a file using the open(). Here is the part of

  • 0

I want to create a file using the open().

Here is the part of my code :

int fd = open("testing", O_EXCL | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
    if(fd == -1){
        perror("Error");
        return 1; }

The output should be a file named “testing” is created, with Read, Write and Execute permission for user, group and others.

But what I get is a file named “testing”, with this permission :

-rwxr-xr-x

The write permission for Group and Others are missing.

I also tried using

S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH |S_IXOTH)

But I still get the same result.

How can I solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:56:26+00:00Added an answer on June 15, 2026 at 7:56 am

    Permissions are modified by the process’ umask. Effective permissions are (mode & ~umask).

    You should change permissions after creating the file, using fchmod(). fchmod() avoids race conditions you could have if you used chmod() and the underlying file changed to point to other inode between the open() and the chmod() (google for TOCTOU races).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I create a .txt file using flex 3? And I want to
This the model that I want to create using json file Ext.define('Users', { extend:
I'm able to create an excel file using apache poi. however, i want users
Using C# and WinForms in VS2008, I want to create a file browser control
I want to create war using grails, but by default it creates war file
I am using phpexcel to create a xls file. I want to turn off
I want to create a file with a block of code in it and
I've created an ics file using DDay iCal library. Now I want to make
I've created a list of files using: file(GLOB_RECURSE DEPLOY_FILES ${PROJECT_SOURCE_DIR}/install/*) I want to install
I want to create a file in the current directory (where the executable is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.