On 30/11/2025 14:09, ASSI via Cygwin-apps wrote:
Jon Turney via Cygwin-apps writes:
The problem is we have a process which goes something like:

- check if F has an existing debuglink section, if so stop
- otherwise, extract symbols from F to F.dbg
- strip symbols from F
- add a debuglink section to F pointing to F.dbg

... which is run in parallel for F=(A, B, C) (which are all hardlinks
for the same file).

So we end up with {A,B,C}.dbg, which are all the same, and only one of
them is actually used.

Except sometimes one of the processes loses the race, so doesn't do
anything because the debuglink already exists.

(which results in a non-deterministic set of files in the output
package archive, which makes the test I've added fail...)

So something like wrapping the whole sequence in

(
   unset __fd
   {__fd}<${exe}

Woah! Shell wizardry! TIL:

"Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {varname}. In this case, for each redirection operator [...], the shell will allocate a file descriptor greater than or equal to 10 and assign it to varname."

It seems like this needs to be preceded by 'exec or ':' to have the desired effect, though.

   flock ${__fd} # maybe we'd want '-w ${timeout}' here
   # …whatever…
)

should fix it?

I guess this isn't completely deterministic (in that we'll get exactly one of A, B or C.dbg), but it's certainly an improvement!

Applied, thanks!

Reply via email to