bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getcwd() returns with stale errno value upon error


From: Martin D Kealey
Subject: Re: getcwd() returns with stale errno value upon error
Date: Thu, 26 Jun 2025 23:14:20 +1000

On Thu, 26 Jun 2025 at 04:07, Oğuz <oguzismailuysal@gmail.com> wrote:

> On Wednesday, June 25, 2025, Richard Weinberger <richard@sigma-star.at>
> wrote:
> >
> >         This can happen on filesystems where d_ino != st_ino
>
> i.e. a broken filesystem.


Or not broken.

There's a fairly obvious race condition where another process replaces a
directory entry between readlink and lstat.


> What does any of this have to do with bash?
>

I would like bash to cope more gracefully with "unexpected" results; I
prefer not should to rush to judgement on whether something else is broken.

PS: Under what circumstances would this occur on Linux, where «
getcwd(buf,size) » is usually implemented as «
readlink("/proc/self/cwd",buf,size) ». (Usually this is *more* reliable,
since it works even when using readdir on "..", "../..", etc is blocked by
filesystem permissions.)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]