File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -1402,6 +1402,16 @@ setTimeout(() => {
14021402}, 2000 );
14031403``` 
14041404
1405+ ### ` subprocess[Symbol.dispose]() `  
1406+ 
1407+ <!--  YAML
1408+ added: REPLACEME 
1409+ --> 
1410+ 
1411+ >  Stability: 1 - Experimental
1412+ 
1413+ Calls [ ` subprocess.kill() ` ] [ ]  with ` 'SIGTERM' ` .
1414+ 
14051415### ` subprocess.killed `  
14061416
14071417<!--  YAML
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const {
1212  ReflectApply, 
1313  StringPrototypeSlice, 
1414  Symbol, 
15+   SymbolDispose, 
1516  Uint8Array, 
1617}  =  primordials ; 
1718
@@ -516,6 +517,12 @@ ChildProcess.prototype.kill = function(sig) {
516517  return  false ; 
517518} ; 
518519
520+ ChildProcess . prototype [ SymbolDispose ]  =  function ( )  { 
521+   if  ( ! this . killed )  { 
522+     this . kill ( ) ; 
523+   } 
524+ } ; 
525+ 
519526
520527ChildProcess . prototype . ref  =  function ( )  { 
521528  if  ( this . _handle )  this . _handle . ref ( ) ; 
Original file line number Diff line number Diff line change 1+ 'use strict' ; 
2+ const  common  =  require ( '../common' ) ; 
3+ const  assert  =  require ( 'assert' ) ; 
4+ const  spawn  =  require ( 'child_process' ) . spawn ; 
5+ const  cat  =  spawn ( common . isWindows  ? 'cmd'  : 'cat' ) ; 
6+ 
7+ cat . stdout . on ( 'end' ,  common . mustCall ( ) ) ; 
8+ cat . stderr . on ( 'data' ,  common . mustNotCall ( ) ) ; 
9+ cat . stderr . on ( 'end' ,  common . mustCall ( ) ) ; 
10+ 
11+ cat . on ( 'exit' ,  common . mustCall ( ( code ,  signal )  =>  { 
12+   assert . strictEqual ( code ,  null ) ; 
13+   assert . strictEqual ( signal ,  'SIGTERM' ) ; 
14+   assert . strictEqual ( cat . signalCode ,  'SIGTERM' ) ; 
15+ } ) ) ; 
16+ cat . on ( 'exit' ,  common . mustCall ( ( code ,  signal )  =>  { 
17+   assert . strictEqual ( code ,  null ) ; 
18+   assert . strictEqual ( signal ,  'SIGTERM' ) ; 
19+   assert . strictEqual ( cat . signalCode ,  'SIGTERM' ) ; 
20+ } ) ) ; 
21+ 
22+ assert . strictEqual ( cat . signalCode ,  null ) ; 
23+ assert . strictEqual ( cat . killed ,  false ) ; 
24+ cat [ Symbol . dispose ] ( ) ; 
25+ assert . strictEqual ( cat . killed ,  true ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments