[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 2c79a8f 2/2: Use posix_spawn if possible.
From: |
Robert Pluim |
Subject: |
Re: master 2c79a8f 2/2: Use posix_spawn if possible. |
Date: |
Tue, 01 Feb 2022 10:59:01 +0100 |
>>>>> On Mon, 31 Jan 2022 22:48:33 +0200, Saulius Menkevicius
>>>>> <sauliusmenkevicius@fastmail.com> said:
Saulius> I did a bit more investigation (and still don't have a reproduction
Saulius> vehicle) but it seems the problem has to do with signals (SIGCHLD
in
Saulius> particular) rather than stdio redirection.
Saulius> Stack trace in the child process shows it has launched a subprocess
Saulius> which has since exited but the child did not receive (?) SIGCHLD
and
Saulius> appears to be blocked.
Saulius> Dotnet stack trace is
Saulius> |[bob@fedora emacs]$ dotnet stack report -p 53193 Thread (0xCFC9):
Saulius> [Native Frames]
Saulius>
System.Private.CoreLib!System.Threading.WaitHandle.WaitOneNoCheck(int32)
Saulius> System.Private.CoreLib!System.Threading.WaitHandle.WaitOne(int32)
Saulius>
System.Diagnostics.Process!System.Diagnostics.ProcessWaitState.WaitForExit(int32)
Saulius>
System.Diagnostics.Process!System.Diagnostics.Process.WaitForExitCore(int32)
Saulius>
Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetDotNetBasePaths>d__5.MoveNext()
Saulius>
Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetInstances>d__4.MoveNext()
Saulius>
Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator+<GetInstances>d__20.MoveNext()
Saulius> System.Linq!System.Linq.Enumerable.TryGetFirst(class
Saulius> System.Collections.Generic.IEnumerable`1<!!0>,bool&)
Saulius> System.Linq!System.Linq.Enumerable.FirstOrDefault(class
Saulius> System.Collections.Generic.IEnumerable`1<!!0>)
Saulius>
Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults()
Saulius> CSharpLanguageServer!CSharpLanguageServer.Program.entry(class
Saulius> System.String[]) |
Saulius> Where "ps axl" shows there is a zombie process waiting to be
collected
Saulius> but is not.
Saulius> |0 1000 53193 53129 20 0 3437284 59416 - Ssl ? 0:00
Saulius>
/home/bob/src/csharp-language-server/src/CSharpLanguageServer/bin/Debug/net6.0/CSharpLanguageServer
Saulius> 0 1000 53203 53193 20 0 0 0 - Z ? 0:00 [dotnet] <defunct> |
Saulius> Related emacs src/callproc.cs has code that has this comment:
Saulius> /* Stop blocking SIGCHLD in the child. */
Saulius> But I really don't know what should I do to attempt to fix
this/find
Saulius> the cause.
Despite the comment, that code doesnʼt actually unblock SIGCHLD, it
just sets the child mask to be the same as the parent, and SIGCHLD and
SIGINT are blocked in the parent at this point.
Try the following:
diff --git a/src/callproc.c b/src/callproc.c
index 4d3b0bb8e0..2b4e8977a3 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1378,6 +1378,12 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t
*attributes)
/* Stop blocking SIGCHLD in the child. */
sigset_t oldset;
error = pthread_sigmask (SIG_SETMASK, NULL, &oldset);
+ if (error != 0)
+ goto out;
+ error = sigdelset (&oldset, SIGCHLD);
+ if (error != 0)
+ goto out;
+ error = sigdelset (&oldset, SIGINT);
if (error != 0)
goto out;
error = posix_spawnattr_setsigmask (attributes, &oldset);
- Re: master 2c79a8f 2/2: Use posix_spawn if possible.,
Robert Pluim <=
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Saulius Menkevicius, 2022/02/01
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Robert Pluim, 2022/02/01
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Eli Zaretskii, 2022/02/01
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Robert Pluim, 2022/02/02
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Saulius Menkevičius, 2022/02/02
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Saulius Menkevicius, 2022/02/07
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Robert Pluim, 2022/02/08
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Eli Zaretskii, 2022/02/08
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Saulius Menkevicius, 2022/02/08
- Re: master 2c79a8f 2/2: Use posix_spawn if possible., Robert Pluim, 2022/02/08