@@ -56,6 +56,24 @@ function resetTerminal(options = {}) {
5656 }
5757}
5858
59+ function getUnsignedExitCode ( code ) {
60+ return code != null && code < 0 ? ( code >>> 0 ) : code
61+ }
62+
63+ function isWindowsNativeCrashCode ( code ) {
64+ const unsignedCode = getUnsignedExitCode ( code )
65+ return (
66+ process . platform === 'win32' &&
67+ ( unsignedCode === 0xC000001D ||
68+ unsignedCode === 0xC0000005 ||
69+ unsignedCode === 0xC0000409 )
70+ )
71+ }
72+
73+ function shouldExitAlternateScreen ( code , signal ) {
74+ return Boolean ( signal ) || isWindowsNativeCrashCode ( code )
75+ }
76+
5977function createConfig ( packageName ) {
6078 const homeDir = os . homedir ( )
6179 const configDir = path . join ( homeDir , '.config' , 'manicode' )
@@ -502,7 +520,9 @@ async function checkForUpdates(runningProcess, exitListener) {
502520 const newChild = spawnInstalledBinary ( { detached : false } )
503521
504522 newChild . on ( 'exit' , ( code , signal ) => {
505- resetTerminal ( { exitAlternateScreen : Boolean ( signal ) } )
523+ resetTerminal ( {
524+ exitAlternateScreen : shouldExitAlternateScreen ( code , signal ) ,
525+ } )
506526 printCrashDiagnostics ( code , signal )
507527 process . exit ( signal ? 1 : ( code || 0 ) )
508528 } )
@@ -516,7 +536,7 @@ async function checkForUpdates(runningProcess, exitListener) {
516536
517537function printCrashDiagnostics ( code , signal ) {
518538 // Windows NTSTATUS codes (unsigned DWORD)
519- const unsignedCode = code != null && code < 0 ? ( code >>> 0 ) : code
539+ const unsignedCode = getUnsignedExitCode ( code )
520540 const isIllegalInstruction =
521541 signal === 'SIGILL' ||
522542 ( process . platform === 'win32' && unsignedCode === 0xC000001D )
@@ -634,7 +654,9 @@ async function main() {
634654 const child = spawnInstalledBinary ( )
635655
636656 const exitListener = ( code , signal ) => {
637- resetTerminal ( { exitAlternateScreen : Boolean ( signal ) } )
657+ resetTerminal ( {
658+ exitAlternateScreen : shouldExitAlternateScreen ( code , signal ) ,
659+ } )
638660 printCrashDiagnostics ( code , signal )
639661 process . exit ( signal ? 1 : ( code || 0 ) )
640662 }
0 commit comments