@@ -121,7 +121,7 @@ export async function startup(argv = ['.', '--no-sandbox']) {
121121 const electron = await import ( 'electron' )
122122 const electronPath = < any > ( electron . default ?? electron )
123123
124- await startup . exit ( )
124+ startup . exit ( )
125125
126126 // Start Electron.app
127127 process . electronApp = spawn ( electronPath , argv , { stdio : 'inherit' } )
@@ -131,31 +131,14 @@ export async function startup(argv = ['.', '--no-sandbox']) {
131131
132132 if ( ! startup . hookedProcessExit ) {
133133 startup . hookedProcessExit = true
134- process . once ( 'exit' , ( ) => {
135- startup . exit ( )
136- // When the process exits, `tree-kill` does not have enough time to complete execution, so `electronApp` needs to be killed immediately.
137- process . electronApp . kill ( )
138- } )
134+ process . once ( 'exit' , startup . exit )
139135 }
140136}
141137startup . hookedProcessExit = false
142138startup . exit = async ( ) => {
143139 if ( process . electronApp ) {
144140 process . electronApp . removeAllListeners ( )
145-
146- await import ( 'tree-kill' )
147- . then ( m => m . default ( process . electronApp . pid ! ) )
148- . catch ( e => {
149- process . electronApp . kill ( )
150-
151- if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
152- console . log (
153- '[vite-plugin-electron]' ,
154- 'Please install tree-kill to exit all associated processes, run "npm i tree-kill -D".' ,
155- )
156- } else {
157- console . error ( e )
158- }
159- } )
141+ // SIGINT can be sent to the process tree #122
142+ process . electronApp . kill ( 'SIGINT' )
160143 }
161144}
0 commit comments