@@ -22,7 +22,9 @@ export class CorpseCmdLet extends CmdLetBase {
2222corpse - create a corpse file` ;
2323
2424 private static readonly CHILD_SLEEP_DURATION : number = 0.1 ;
25- private static readonly CHILD_WAIT_DURATION : number = 10 ;
25+ private static readonly PARENT_SLEEP_DURATION : number = 0.5 ;
26+ private static readonly WAIT_DURATION : number = 20 ;
27+ private static readonly PARENT_DELAY_DURATION : number = 2 ;
2628 private static readonly ELF_MAGIC : number = 0x7f454c46 ;
2729
2830 private rlimit : Rlimit | null = null ;
@@ -158,15 +160,30 @@ corpse - create a corpse file`;
158160 this . debug ( `Running parent, pid: ${ Process . id } , child pid: ${ childPid } ` ) ;
159161
160162 const proc = this . proc as Proc ;
161- for ( let i = 0 ; i < 10 ; i ++ ) {
163+
164+ this . debug ( `Delaying: ${ CorpseCmdLet . PARENT_DELAY_DURATION } s` ) ;
165+ Thread . sleep ( CorpseCmdLet . PARENT_DELAY_DURATION ) ;
166+
167+ const limit =
168+ CorpseCmdLet . WAIT_DURATION / CorpseCmdLet . PARENT_SLEEP_DURATION ;
169+
170+ this . debug ( `Parent limit: ${ limit } ` ) ;
171+ this . debug ( `Delay between signals: ${ CorpseCmdLet . PARENT_SLEEP_DURATION } s` ) ;
172+ for ( let i = 0 ; i < limit ; i ++ ) {
162173 proc . kill ( childPid , Proc . SIGABRT ) ;
163174
164175 const status = proc . waitpid ( childPid ) ;
165- this . debug ( `status - exitStatus: ${ status . exitStatus } ,
166- termSignal: ${ status . termSignal } , stopped: ${ status . stopped } ` ) ;
176+ this . debug (
177+ [
178+ `index: ${ i } ,` ,
179+ `exitStatus: ${ status . exitStatus } ,` ,
180+ `termSignal: ${ status . termSignal } ,` ,
181+ `stopped: ${ status . stopped } ` ,
182+ ] . join ( ' ' ) ,
183+ ) ;
167184
168185 if ( status . stopped ) return ;
169- Thread . sleep ( 0.5 ) ;
186+ Thread . sleep ( CorpseCmdLet . PARENT_SLEEP_DURATION ) ;
170187 }
171188 this . status ( `Child not stopped, pid: ${ childPid } ` ) ;
172189 proc . kill ( childPid , Proc . SIGKILL ) ;
@@ -181,10 +198,13 @@ corpse - create a corpse file`;
181198
182199 try {
183200 const limit =
184- CorpseCmdLet . CHILD_WAIT_DURATION / CorpseCmdLet . CHILD_SLEEP_DURATION ;
201+ CorpseCmdLet . WAIT_DURATION / CorpseCmdLet . CHILD_SLEEP_DURATION ;
202+ debug ( `Child limit: ${ limit } ` ) ;
203+ debug ( `Delay between sleeps: ${ CorpseCmdLet . CHILD_SLEEP_DURATION } s` ) ;
185204 for ( let i = 0 ; i < limit ; i ++ ) {
186205 Thread . sleep ( CorpseCmdLet . CHILD_SLEEP_DURATION ) ;
187206 }
207+ debug ( `Child limit exceeded` ) ;
188208 } catch ( error ) {
189209 if ( error instanceof Error ) {
190210 debug ( `ERROR: ${ error . message } ` ) ;
0 commit comments