Skip to content

Commit b6ba40f

Browse files
perlunamaitland
authored andcommitted
Bug fix: handle type=crashpad-handler (#2449)
I was seeing instances of the subprocess being spawned this way when running the CefSharp.Wpf.Example project. Debugging showed me that no such argument was being passed to the process. This PR works around the issue by opting out from getting the parent process ID for such processes.
1 parent e1d4d3c commit b6ba40f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

CefSharp.BrowserSubprocess/Program.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.Diagnostics;
7+
using System.Linq;
78
using System.Threading.Tasks;
89
using CefSharp.Internals;
910

@@ -19,13 +20,21 @@ public static int Main(string[] args)
1920

2021
int result;
2122
var type = args.GetArgumentValue(CefSharpArguments.SubProcessTypeArgument);
22-
var parentProcessId = int.Parse(args.GetArgumentValue(CefSharpArguments.HostProcessIdArgument));
23-
if (args.HasArgument(CefSharpArguments.ExitIfParentProcessClosed))
23+
24+
var parentProcessId = -1;
25+
26+
// The Crashpad Handler doesn't have any HostProcessIdArgument, so we must not try to
27+
// parse it lest we want an ArgumentNullException.
28+
if (type != "crashpad-handler")
2429
{
25-
Task.Factory.StartNew(() => AwaitParentProcessExit(parentProcessId), TaskCreationOptions.LongRunning);
30+
parentProcessId = int.Parse(args.GetArgumentValue(CefSharpArguments.HostProcessIdArgument));
31+
if (args.HasArgument(CefSharpArguments.ExitIfParentProcessClosed))
32+
{
33+
Task.Factory.StartNew(() => AwaitParentProcessExit(parentProcessId), TaskCreationOptions.LongRunning);
34+
}
2635
}
2736

28-
//Use our custom subProcess provides features like EvaluateJavascript
37+
// Use our custom subProcess provides features like EvaluateJavascript
2938
if (type == "renderer")
3039
{
3140
var wcfEnabled = args.HasArgument(CefSharpArguments.WcfEnabledArgument);

0 commit comments

Comments
 (0)