Bug 1340735 - Terminate process when failing to attach it to job group. r?mhowell draft
authorKris Maglione <maglione.k@gmail.com>
Fri, 17 Feb 2017 15:30:24 -0800
changeset 486467 12926d158c39e72b3753e223271b5e72f2863dcf
parent 486323 e5c3d1b928cf814751ac91369d1703f4e0e90022
child 546249 f29c32c79fa60964e9e5281c99ae558ff3540b9c
push id45987
push usermaglione.k@gmail.com
push dateFri, 17 Feb 2017 23:31:23 +0000
reviewersmhowell
bugs1340735
milestone54.0a1
Bug 1340735 - Terminate process when failing to attach it to job group. r?mhowell MozReview-Commit-ID: BVCPRFH6TV2
toolkit/modules/subprocess/subprocess_worker_win.js
--- a/toolkit/modules/subprocess/subprocess_worker_win.js
+++ b/toolkit/modules/subprocess/subprocess_worker_win.js
@@ -516,17 +516,20 @@ class Process extends BaseProcess {
       ok = libc.SetInformationJobObject(this.jobHandle, win32.JobObjectExtendedLimitInformation,
                                         ctypes.cast(info.address(), ctypes.voidptr_t),
                                         info.constructor.size);
       errorMessage = `Failed to set job limits: 0x${(ctypes.winLastError || 0).toString(16)}`;
     }
 
     if (ok) {
       ok = libc.AssignProcessToJobObject(this.jobHandle, procInfo.hProcess);
-      errorMessage = `Failed to attach process to job object: 0x${(ctypes.winLastError || 0).toString(16)}`;
+      if (!ok) {
+        libc.TerminateProcess(procInfo.hProcess, TERMINATE_EXIT_CODE);
+        errorMessage = `Failed to attach process to job object: 0x${(ctypes.winLastError || 0).toString(16)}`;
+      }
     }
 
     if (!ok) {
       for (let pipe of this.pipes) {
         pipe.close();
       }
       throw new Error(errorMessage);
     }