Skip to content

Commit 4f1a2b7

Browse files
committed
Only close process on success
1 parent ba560ce commit 4f1a2b7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/WebJobs.Script/Workers/ProcessManagement/WorkerProcess.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ private void OnProcessExited(object sender, EventArgs e)
182182
try
183183
{
184184
ThrowIfExitError();
185-
186-
Process.WaitForExit();
187185
if (Process.ExitCode == WorkerConstants.IntentionalRestartExitCode)
188186
{
189187
HandleWorkerProcessRestart();
@@ -203,8 +201,14 @@ private void OnProcessExited(object sender, EventArgs e)
203201
finally
204202
{
205203
_processExit.TrySetResult(Process.ExitCode);
204+
205+
if (Process.ExitCode == WorkerConstants.SuccessExitCode)
206+
{
207+
Process.WaitForExit();
208+
Process.Close();
209+
}
210+
206211
UnregisterFromProcessMonitor();
207-
Process.Close();
208212
}
209213
}
210214

0 commit comments

Comments
 (0)