File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,7 +109,13 @@ export class Terminal {
109109 private readonly _pty : IPtyBackend ;
110110 private readonly _term : xterm . Terminal ;
111111 private readonly _returnChar : string ;
112- private _exited : boolean = false ;
112+ private _exitResult : { exitCode : number ; signal ?: number } | null = null ;
113+ private get _exited ( ) : boolean {
114+ return this . _exitResult !== null ;
115+ }
116+ get exitResult ( ) {
117+ return this . _exitResult ;
118+ }
113119 readonly onExit : (
114120 callback : ( exit : { exitCode : number ; signal ?: number } ) => void
115121 ) => void ;
@@ -138,10 +144,16 @@ export class Terminal {
138144 }
139145 this . _term . write ( data ) ;
140146 } ) ;
141- this . _pty . onExit ( ( ) => {
142- this . _exited = true ;
147+ this . _pty . onExit ( ( exitResult ) => {
148+ this . _exitResult = exitResult ;
143149 } ) ;
144- this . onExit = ( callback ) => this . _pty . onExit ( callback ) ;
150+ this . onExit = ( callback ) => {
151+ if ( this . _exitResult ) {
152+ callback ( this . _exitResult ) ;
153+ } else {
154+ this . _pty . onExit ( callback ) ;
155+ }
156+ } ;
145157 }
146158
147159 /**
You can’t perform that action at this time.
0 commit comments