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

P

pshyamsunder

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
 
S

Suman

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.

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.
If I close "File1" before making a call to access() on "File2", then it
works. Why is this behavior?

No idea!
 
C

CBFalconer

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?

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.com, 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.
 
P

pshyamsunder

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

Keith Thompson

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?

access() is not defined by the C standard. Try comp.unix.programmer.
 
R

Randy Howard

(e-mail address removed) wrote
(in article
access() is an api available on Unix to determine accessibility of a
file. It is on all standard Unix flavors.

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

Flash Gordon

Suman said:
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.

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.

At a guess there is some other problem with the code.
 
H

Hari

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?

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.
 
L

Lawrence Kirby

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

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

Lawrence
 
C

CBFalconer

Suman said:
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.


No idea!

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.
 
S

Suman

CBFalconer said:
Suman wrote:
[...]
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.
[...]
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.

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.
 
C

CBFalconer

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

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.
 
K

Kenny McCormack

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.

Or, ...

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

(And, why should he?)
 
F

Flash Gordon

Suman said:
CBFalconer said:
Suman wrote:
[...]
Did you check for the error? aceess() on failure should set errno.
^^^^^^^^
As far as I can see the above says access() NOT fopen()
See if you can find out something. Guessing won't take us any
further.

[...]
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.

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.

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.
> Being rude
and showing him the door, was a possibility,

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

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

The problem was access() failing, NOT fopen() failing, and your answer
was talking purely about access() NOT fopen().
Sometimes, the line is far too thin. For me.

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.
 
K

Kenny McCormack

(Blah, blah, blah, the typical verbal venting that passes for Flash's sex
life...)
(leading to...)
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.

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top