File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,34 @@ function onexit() {
135135 console . error ( ) ;
136136 throw e ;
137137 }
138+
139+ openFilesCheck ( ) ;
140+ }
141+
142+ function openFilesCheck ( ) {
143+ const cmd = `lsof -p ${ process . pid } ` ;
144+
145+ if ( process . platform !== 'linux' )
146+ return ;
147+
148+ let openFiles ;
149+ try {
150+ openFiles = execSync ( cmd , { encoding : 'utf8' } ) ;
151+ } catch {
152+ // Ignore errors
153+ return ;
154+ }
155+
156+ const openFilesLines = openFiles . trim ( ) . split ( / \r ? \n / ) ;
157+ const tmpFiles =
158+ openFilesLines . filter ( ( l ) => ( l . indexOf ( `${ tmpdirName } /` ) !== - 1 ) ) ;
159+
160+ if ( tmpFiles . length > 0 ) {
161+ console . error ( 'Open files in tmpPath:' ) ;
162+ console . error ( openFilesLines [ 0 ] ) ; // header
163+ console . error ( tmpFiles . join ( '\n' ) ) ;
164+ throw new Error ( 'Open files found in tmpPath' ) ;
165+ }
138166}
139167
140168module . exports = {
You can’t perform that action at this time.
0 commit comments