import { postTelemetryInBackground , tracer } from '.' ; import { KilledError } from '../errors' ; export function registerSigintHandler ( opts ) { process . on ( 'SIGINT' , ( ) => { console . log ( `Gracefully terminating...` ) ; const err = new KilledError ( ) ; tracer . allSpans . forEach ( ( s ) => s . end ( err ) ) ; postTelemetryInBackground ( { commandName : opts . commandName , canonicalCommandName : opts . canonicalCommandName , durationMiliSeconds : Date . now ( ) - opts . startTime , err : { errName : err . name , errMessage : err . message , errStack : err . stack || '' , } , } ) ; process . exit ( 0 ) ; } ) ; }