@@ -173,6 +173,9 @@ function releaseBuild() {
173
173
is_building = false ;
174
174
}
175
175
}
176
+
177
+ // We use [~perm:0o664] rather than our usual default perms, [0o666], because
178
+ // lock files shouldn't rely on the umask to disallow tampering by other.
176
179
function acquireBuild ( ) {
177
180
if ( is_building ) {
178
181
return false ;
@@ -285,55 +288,30 @@ if (
285
288
286
289
function onUncaughtException ( err ) {
287
290
console . error ( "Uncaught Exception" , err ) ;
291
+ releaseBuild ( ) ;
288
292
process . exit ( 1 ) ;
289
293
}
290
- function onExit ( ) {
291
- try {
292
- fs . unlinkSync ( lockFileName ) ;
293
- } catch ( err ) {
294
- process . exitCode = 1 ;
295
- }
296
- }
297
294
function exitProcess ( ) {
295
+ releaseBuild ( ) ;
298
296
process . exit ( 0 ) ;
299
297
}
300
298
301
- /**
302
- * @return {boolean }
303
- */
304
- function acquireLockFile ( ) {
305
- try {
306
- // We use [~perm:0o664] rather than our usual default perms, [0o666], because
307
- // lock files shouldn't rely on the umask to disallow tampering by other.
308
- var fd = fs . openSync ( lockFileName , "wx" , 0o664 ) ;
309
- try {
310
- fs . writeFileSync ( fd , String ( process . pid ) , "ascii" ) ;
311
- fs . closeSync ( fd ) ;
312
- } catch ( err ) { }
313
-
314
- process . on ( "exit" , onExit ) ;
315
- process . on ( "uncaughtException" , onUncaughtException ) ;
299
+ process . on ( "uncaughtException" , onUncaughtException ) ;
316
300
317
- // OS signal handlers
318
- // Ctrl+C
319
- process . on ( "SIGINT" , exitProcess ) ;
320
- // kill pid
321
- process . on ( "SIGUSR1" , exitProcess ) ;
322
- process . on ( "SIGUSR2" , exitProcess ) ;
323
- process . on ( "SIGTERM" , exitProcess ) ;
324
- process . on ( "SIGHUP" , exitProcess ) ;
301
+ // OS signal handlers
302
+ // Ctrl+C
303
+ process . on ( "SIGINT" , exitProcess ) ;
304
+ // kill pid
305
+ process . on ( "SIGUSR1" , exitProcess ) ;
306
+ process . on ( "SIGUSR2" , exitProcess ) ;
307
+ process . on ( "SIGTERM" , exitProcess ) ;
308
+ process . on ( "SIGHUP" , exitProcess ) ;
325
309
326
- process . stdin . on ( "close" , exitProcess ) ;
327
- // close when stdin stops
328
- if ( os . platform ( ) !== "win32" ) {
329
- process . stdin . on ( "end" , exitProcess ) ;
330
- process . stdin . resume ( ) ;
331
- }
332
-
333
- return true ;
334
- } catch ( exn ) {
335
- return false ;
336
- }
310
+ process . stdin . on ( "close" , exitProcess ) ;
311
+ // close when stdin stops
312
+ if ( os . platform ( ) !== "win32" ) {
313
+ process . stdin . on ( "end" , exitProcess ) ;
314
+ process . stdin . resume ( ) ;
337
315
}
338
316
339
317
var sourcedirs = path . join ( "lib" , "bs" , ".sourcedirs.json" ) ;
0 commit comments