access() doesn't work when a file is open

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pshyamsunder@yahoo.com

    access() doesn't work when a file is open

    Hi:

    I am facing a strange problem.

    I have opened a file "File1" using fopen() and while processing the
    records in the file in a loop, I have a call to access() to check
    existence of "File2". The reason is to stop processing further records
    when the file "File2" exists. But the access() call fails when the file
    "File1" is open.

    If I close "File1" before making a call to access() on "File2", then it
    works. Why is this behavior?

    Please help. And please excuse my C ignorance.

    Regds..Shyam

  • Suman

    #2
    Re: access() doesn't work when a file is open


    pshyamsunder@ya hoo.com wrote:[color=blue]
    > Hi:
    >
    > I am facing a strange problem.
    >
    > I have opened a file "File1" using fopen() and while processing the
    > records in the file in a loop, I have a call to access() to check
    > existence of "File2". The reason is to stop processing further records
    > when the file "File2" exists. But the access() call fails when the file
    > "File1" is open.[/color]

    Did you check for the error? aceess() on failure should set errno.
    See if you can find out something. Guessing won't take us any further.
    [color=blue]
    > If I close "File1" before making a call to access() on "File2", then it
    > works. Why is this behavior?[/color]

    No idea!

    Comment

    • CBFalconer

      #3
      Re: access() doesn't work when a file is open

      pshyamsunder@ya hoo.com wrote:[color=blue]
      >
      > I have opened a file "File1" using fopen() and while processing
      > the records in the file in a loop, I have a call to access() to
      > check existence of "File2". The reason is to stop processing
      > further records when the file "File2" exists. But the access()
      > call fails when the file "File1" is open.
      >
      > If I close "File1" before making a call to access() on "File2",
      > then it works. Why is this behavior?[/color]

      There is no such function as access() in standard C, so it must be
      something you wrote yourself or provided by your system. This
      makes the subject off-topic here. You can either provide the full
      source of access(), together with your actual code, when we will be
      able to comment on it, or you should find a newsgroup that deals
      with your system.

      If you want to post a followup via groups.google.c om, don't use the
      broken "Reply" link at the bottom of the article. Click on "show
      options" at the top of the article, then click on the "Reply" at
      the bottom of the article headers.

      --
      Chuck F (cbfalconer@yah oo.com) (cbfalconer@wor ldnet.att.net)
      Available for consulting/temporary embedded and systems.
      <http://cbfalconer.home .att.net> USE worldnet address!


      Comment

      • pshyamsunder@yahoo.com

        #4
        Re: access() doesn't work when a file is open

        access() is an api available on Unix to determine accessibility of a
        file. It is on all standard Unix flavors.

        Comment

        • Keith Thompson

          #5
          Re: access() doesn't work when a file is open

          pshyamsunder@ya hoo.com writes:[color=blue]
          > I am facing a strange problem.
          >
          > I have opened a file "File1" using fopen() and while processing the
          > records in the file in a loop, I have a call to access() to check
          > existence of "File2". The reason is to stop processing further records
          > when the file "File2" exists. But the access() call fails when the file
          > "File1" is open.
          >
          > If I close "File1" before making a call to access() on "File2", then it
          > works. Why is this behavior?[/color]

          access() is not defined by the C standard. Try comp.unix.progr ammer.

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
          We must do something. This is something. Therefore, we must do this.

          Comment

          • Randy Howard

            #6
            Re: access() doesn't work when a file is open

            pshyamsunder@ya hoo.com wrote
            (in article
            <1125045444.270 053.77000@g43g2 000cwa.googlegr oups.com>):
            [color=blue]
            > access() is an api available on Unix to determine accessibility of a
            > file. It is on all standard Unix flavors.[/color]

            Then one of the comp.unix.* newsgroups is probably a good place
            to start, huh?


            --
            Randy Howard (2reply remove FOOBAR)

            Comment

            • Flash Gordon

              #7
              Re: access() doesn't work when a file is open

              Suman wrote:[color=blue]
              > pshyamsunder@ya hoo.com wrote:
              >[color=green]
              >>Hi:
              >>
              >>I am facing a strange problem.
              >>
              >>I have opened a file "File1" using fopen() and while processing the
              >>records in the file in a loop, I have a call to access() to check
              >>existence of "File2". The reason is to stop processing further records
              >>when the file "File2" exists. But the access() call fails when the file
              >>"File1" is open.[/color]
              >
              > Did you check for the error? aceess() on failure should set errno.
              > See if you can find out something. Guessing won't take us any further.[/color]

              Also take this to a group where it is topical please. access() is not
              part of the C standard and may behave completely differently on
              different implementations . It might, for example, try to open a
              connection to an Access database.
              [color=blue][color=green]
              >>If I close "File1" before making a call to access() on "File2", then it
              >>works. Why is this behavior?[/color]
              >
              > No idea![/color]

              At a guess there is some other problem with the code.
              --
              Flash Gordon
              Living in interesting times.
              Although my email address says spam, it is real and I read it.

              Comment

              • Lawrence Kirby

                #8
                Re: access() doesn't work when a file is open

                On Fri, 26 Aug 2005 01:37:24 -0700, pshyamsunder wrote:
                [color=blue]
                > access() is an api available on Unix to determine accessibility of a
                > file. It is on all standard Unix flavors.[/color]

                However comp.lang.c is not for discussing Unix APIs, a good place for that
                is comp.unix.progr ammer.

                Lawrence

                Comment

                • Hari

                  #9
                  Re: access() doesn't work when a file is open

                  On Fri, 26 Aug 2005 00:17:32 -0700, pshyamsunder wrote:
                  [color=blue]
                  > Hi:
                  >
                  > I am facing a strange problem.
                  >
                  > I have opened a file "File1" using fopen() and while processing the
                  > records in the file in a loop, I have a call to access() to check
                  > existence of "File2". The reason is to stop processing further records
                  > when the file "File2" exists. But the access() call fails when the file
                  > "File1" is open.
                  >
                  > If I close "File1" before making a call to access() on "File2", then it
                  > works. Why is this behavior?[/color]

                  First of all this is off-topic. And the second thing is your question is
                  too vague. You have not mentioned the error returned by access() call.
                  Please check man page, it contains a lot of information.
                  [color=blue]
                  >
                  > Please help. And please excuse my C ignorance.
                  >
                  > Regds..Shyam[/color]

                  --
                  Hari

                  Comment

                  • CBFalconer

                    #10
                    Re: access() doesn't work when a file is open

                    Suman wrote:[color=blue]
                    > pshyamsunder@ya hoo.com wrote:[color=green]
                    >>
                    >> I have opened a file "File1" using fopen() and while processing
                    >> the records in the file in a loop, I have a call to access() to
                    >> check existence of "File2". The reason is to stop processing
                    >> further records when the file "File2" exists. But the access()
                    >> call fails when the file "File1" is open.[/color]
                    >
                    > Did you check for the error? aceess() on failure should set errno.
                    > See if you can find out something. Guessing won't take us any
                    > further.
                    >[color=green]
                    >> If I close "File1" before making a call to access() on "File2",
                    >> then it works. Why is this behavior?[/color]
                    >
                    > No idea![/color]

                    Please do not answer off-topic enquiries, other than to suggest an
                    appropriate newsgroup. One reason is that there is nobody here (in
                    principle) to criticize an off-topic reply content. Another is
                    that it clutters the newsgroup.

                    --
                    "If you want to post a followup via groups.google.c om, don't use
                    the broken "Reply" link at the bottom of the article. Click on
                    "show options" at the top of the article, then click on the
                    "Reply" at the bottom of the article headers." - Keith Thompson

                    Comment

                    • Suman

                      #11
                      Re: access() doesn't work when a file is open


                      CBFalconer wrote:[color=blue]
                      > Suman wrote:
                      >[...][color=green]
                      > > Did you check for the error? aceess() on failure should set errno.
                      > > See if you can find out something. Guessing won't take us any
                      > > further.
                      > >[/color]
                      > [...]
                      > Please do not answer off-topic enquiries, other than to suggest an
                      > appropriate newsgroup. One reason is that there is nobody here (in
                      > principle) to criticize an off-topic reply content. Another is
                      > that it clutters the newsgroup.
                      >[/color]

                      It was my own way of saying, do the needful before posting, and also
                      an attempt to make the OP come back with *some* C code. Being rude
                      and showing him the door, was a possibility, but I did flirt a little
                      with rules, I suppose.

                      `fopen()': I believe is on-topic -- thence the gaul to take
                      such latitude.

                      Sometimes, the line is far too thin. For me.

                      Comment

                      • CBFalconer

                        #12
                        Re: access() doesn't work when a file is open

                        pshyamsunder@ya hoo.com wrote:[color=blue]
                        >
                        > access() is an api available on Unix to determine accessibility of a
                        > file. It is on all standard Unix flavors.[/color]

                        I don't think you will go far. I gave you explicit instructions
                        about how to compose a reply in google groups, and you ignored them
                        and everything else I told you. This shows either an appalling
                        inability to learn or insufferable rudeness.

                        --
                        "If you want to post a followup via groups.google.c om, don't use
                        the broken "Reply" link at the bottom of the article. Click on
                        "show options" at the top of the article, then click on the
                        "Reply" at the bottom of the article headers." - Keith Thompson

                        Comment

                        • Kenny McCormack

                          #13
                          Re: access() doesn't work when a file is open

                          In article <430F1C05.42DAA D3D@yahoo.com>,
                          CBFalconer <cbfalconer@wor ldnet.att.net> wrote:[color=blue]
                          >pshyamsunder@y ahoo.com wrote:[color=green]
                          >>
                          >> access() is an api available on Unix to determine accessibility of a
                          >> file. It is on all standard Unix flavors.[/color]
                          >
                          >I don't think you will go far. I gave you explicit instructions
                          >about how to compose a reply in google groups, and you ignored them
                          >and everything else I told you. This shows either an appalling
                          >inability to learn or insufferable rudeness.[/color]

                          Or, ...

                          It shows that he just don't kowtow to you!

                          (And, why should he?)

                          Comment

                          • Flash Gordon

                            #14
                            Re: access() doesn't work when a file is open

                            Suman wrote:[color=blue]
                            > CBFalconer wrote:
                            >[color=green]
                            >>Suman wrote:
                            >>[...]
                            >>[color=darkred]
                            >>>Did you check for the error? aceess() on failure should set errno.[/color][/color][/color]
                            ^^^^^^^^
                            As far as I can see the above says access() NOT fopen()
                            [color=blue][color=green][color=darkred]
                            >>>See if you can find out something. Guessing won't take us any
                            >>>further.[/color]
                            >>
                            >>[...]
                            >>Please do not answer off-topic enquiries, other than to suggest an
                            >>appropriate newsgroup. One reason is that there is nobody here (in
                            >>principle) to criticize an off-topic reply content. Another is
                            >>that it clutters the newsgroup.[/color]
                            >
                            > It was my own way of saying, do the needful before posting, and also
                            > an attempt to make the OP come back with *some* C code.[/color]

                            When the problem, as in the OPs case, is a function that is OFF TOPIC
                            getting them to post it here is not appropriate.

                            If the OP can demonstrate a problem with only standard C functions then
                            *that* would have been on topic.
                            [color=blue]
                            > Being rude
                            > and showing him the door, was a possibility,[/color]

                            Others redirected the OP moderately politely to other groups. Pointing
                            the OP at where the
                            [color=blue]
                            > but I did flirt a little
                            > with rules, I suppose.[/color]

                            No, you talked about something completely off topic, namely access().
                            [color=blue]
                            > `fopen()': I believe is on-topic -- thence the gaul to take
                            > such latitude.[/color]

                            The problem was access() failing, NOT fopen() failing, and your answer
                            was talking purely about access() NOT fopen().
                            [color=blue]
                            > Sometimes, the line is far too thin. For me.[/color]

                            I would have said it was rather obvious that if your answer is just
                            talking about a function outside the scope of this group, namely the
                            behaviour of access() in this case, that is was off topic.
                            --
                            Flash Gordon
                            Living in interesting times.
                            Although my email address says spam, it is real and I read it.

                            Comment

                            • Kenny McCormack

                              #15
                              Re: access() doesn't work when a file is open

                              In article <hjn3u2xpu7.ln2 @brenda.flash-gordon.me.uk>,
                              Flash Gordon <spam@flash-gordon.me.uk> wrote:
                              (Blah, blah, blah, the typical verbal venting that passes for Flash's sex
                              life...)
                              (leading to...)[color=blue][color=green]
                              >> Sometimes, the line is far too thin. For me.[/color]
                              >
                              >I would have said it was rather obvious that if your answer is just
                              >talking about a function outside the scope of this group, namely the
                              >behaviour of access() in this case, that is was off topic.[/color]

                              So, be a man! Do what Americans do! Sue him!

                              (Don't take being off-topic into your own hands. Take him to court!!!)

                              See ya in court!

                              Comment

                              Working...