[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Competition among multiple `mkdir -p` processes on the same director
Re: Competition among multiple `mkdir -p` processes on the same directory
Thu, 9 Feb 2023 10:38:10 -0600
See below. coreutils' `mkdir -p` does not have this problem. I guess
it is because it first tries to create the directory by the system
call mkdir. On error, it will check whether the target is a directory,
if it is a directory, then it will not complain about the error.
Based on the error message of bash loadable `mkdir -p`, it seems the
logic is the opposite. My guess is that it first checks if the target
exists. If it doesn't exist, then it creates the directory. But when
multiple instances of bash loadable `mkdir -p` are called
simultaneously, they all first find there is not a target. Then they
all try to create it, but only one instance will be successful. The
rest will fail and print error messages. This seems to be a bug in
bash loadable mkdir.
I am trying to use the following dtruss command to see what bash
loadable mkdir does under the hood. But nothing about system function
mkdir is printed.
sudo dtruss bash -c 'builtin enable -f mkdir mkdir; builtin mkdir -p d'
What is the correct way to check what bash loadable mkdir does under the hood?
On 2/8/23, Peng Yu <firstname.lastname@example.org> wrote:
> I forgot to mention that I was referring to mkdir from loadables.
> On 2/8/23, Peng Yu <email@example.com> wrote:
>> When I simultaneously issue `mkdir -p` for the same directory, i
>> sometimes see error messages like the following. Is it a bug? I don't
>> remember seeing this kind of error when I use mkdir from coreutils.
>> xxx.sh: line 30: mkdir: cannot create directory `d': File exists