Subject: bug#70415: 30.0.50; [Cygwin] `lock-file' creates a symlink with funny name

From: Ken Brown <[email-masked]>
Date: Sat, 4 May 2024 13:15:19 -0400

On 5/2/2024 10:26 AM, Ken Brown wrote:
> On 5/2/2024 2:21 AM, Eli Zaretskii wrote:
>>> Date: Wed, 1 May 2024 17:20:20 -0400
>>> Cc: [email-masked], [email-masked]
>>> From: Ken Brown <[email-masked]>
>>>
>>>>       char const *lock_info_fmt = (boot
>>>>                  ? "%s@%s.%"PRIdMAX":%"PRIdMAX
>>>>                  : "%s@%s.%"PRIdMAX);
>>>>       int len = snprintf (lock_info_str, sizeof lock_info_str,
>>>>             lock_info_fmt, user_name, host_name, pid, boot);
>>>>
>>>> get_boot_sec calls get_boot_time, which is a Gnulib function (see
>>>> lib/boot-time.c).  So I guess the key to unlock this puzzle is
>>>> somewhere there.
>>>
>>> I took a quick look at get_boot_time and found a bug, which may explain
>>> why some Cygwin systems behave differently from others.  I've reported
>>> it here:
>>>
>>>     https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00008.html
>>
>> Thanks.  This probably explains why the ":-NNNN" part sometimes
>> appears and sometimes doesn't appear in Cygwin builds of Emacs, but
>> AFAIU it does NOT explain why unlinking the symlink (when the file is
>> unlocked) fails when the lock file name includes the ":-NNNN" part.
>> Right?
> 
> Yes, that's right.  I still need to look into that.

It turns out that there was a Cygwin bug (already fixed in the Cygwin 
development sources) that affected only version 3.5.3, and Bruno added a 
workaround to Gnulib.  I now see the ":NNNN" part on my system, without 
a minus sign, and the lock file is deleted properly.

Katsumi, can you apply Bruno's two patches and confirm that the bug is 
fixed?

Ken