From 3fc7357e3fc65dfb33a327cee3f77a30ebae72f0 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 19 Jan 2022 10:15:51 +0100 Subject: [PATCH] util: Restore the NOFILE limit before spawning apps Make sure the restore the original NOFILE limit prior to run the commands so those don't inherit from the raised value. Part-of: --- js/misc/util.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/js/misc/util.js b/js/misc/util.js index da768566a..bea2cfe85 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -111,9 +111,16 @@ function spawnApp(argv) { function trySpawn(argv) { var success_, pid; try { - [success_, pid] = GLib.spawn_async(null, argv, null, - GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD, - null); + [success_, pid] = GLib.spawn_async( + null, argv, null, + GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD, + () => { + try { + global.context.restore_rlimit_nofile(); + } catch (err) { + } + } + ); } catch (err) { /* Rewrite the error in case of ENOENT */ if (err.matches(GLib.SpawnError, GLib.SpawnError.NOENT)) {