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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2117>
This commit is contained in:
Olivier Fourdan 2022-01-19 10:15:51 +01:00
parent bafacdf629
commit 3fc7357e3f

View File

@ -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)) {