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 6585091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:37:05+00:00 2026-05-25T16:37:05+00:00

I have a small program below on 2.6.16-rc3, which uses busy box (on jffs2

  • 0

I have a small program below on 2.6.16-rc3, which uses busy box (on jffs2 file system).
If I run the program multiple times, it starts to fail second time onwards . When the program quits, the descriptors shall be auto closed and next time it shall start fresh , right ?

Why I am getting -1 some times? (Note – On my Fedora Linux PC , it works fine)

root@badge 07:29:32 ~ >touch Hello.txt
root@badge 07:29:37 ~ >./a.out
FP = 3
root@badge 07:29:38 ~ >./a.out
FP = -1
root@badge 07:29:40 ~ >./a.out
FP = 3
root@badge 07:29:41 ~ >./a.out
FP = -1
root@badge 07:29:42 ~ >./a.out
FP = 3
root@badge 07:29:43 ~ >./a.out
FP = 3
root@badge 07:29:43 ~ >./a.out
FP = -1
root@badge 07:29:45 ~ >

Program:

#include <stdio.h>
int main()
{
        int fp;
        fp = open ("Hello.txt");
        printf("FP = %d\n", fp);
        return 0;  // No close() is used. On exit, it shall be closed.
}

Text File:

    -rw-r--r--    1 root     root            0 Sep 20 07:22 Hello.txt
  • 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-05-25T16:37:06+00:00Added an answer on May 25, 2026 at 4:37 pm

    You’re not following the contract of the open() call. The man page (on Linux) states this:

    SYNOPSIS
           #include <sys/types.h>
           #include <sys/stat.h>
           #include <fcntl.h>
    
           int open(const char *pathname, int flags);
           int open(const char *pathname, int flags, mode_t mode);
    
           int creat(const char *pathname, mode_t mode);
    

    As you can see, you’re forgetting to include the right headers, and open() also takes a flags parameter where you would state read/write rights, etc. As this is laid out you’ll get a mystery argument passed to open(), this is whatever was on the stack or in the registers at the time.

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

Sidebar

Related Questions

I have a small Python program, which uses a Google Maps API secret key.
I currently have a small Java program which I would like to run both
I have a small command line program that uses the Team System API. When
I have a problem with a small program that i made. Below is the
I have a small program to order and sort email messages, outputting to a
I have a small program <350ish lines of code on 5 forms>. It works
i have a small program where an element is draged and dropped, when the
I have a small program to do in Java. I have a 2D array
I have a small program I want to execute to test something #include <map>
I have a small server program that accepts connections on a TCP or local

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.