js/environment: Always use Shell.util_spawn_async functions if possible
If no child setup is provided then all the shell extensions that use GLib.spawn_async should actually use the shell spawning utils since we are supposed to always restore the default nofile rlimit on launched children. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3293>
This commit is contained in:
parent
494be30764
commit
64edd7940d
@ -348,14 +348,17 @@ if (slowdownEnv) {
|
|||||||
function wrapSpawnFunction(func) {
|
function wrapSpawnFunction(func) {
|
||||||
const originalFunc = GLib[func];
|
const originalFunc = GLib[func];
|
||||||
return function (workingDirectory, argv, envp, flags, childSetup, ...args) {
|
return function (workingDirectory, argv, envp, flags, childSetup, ...args) {
|
||||||
|
const commonArgs = [workingDirectory, argv, envp, flags];
|
||||||
if (childSetup) {
|
if (childSetup) {
|
||||||
logError(new Error(`Using child GLib.${func} with a GLib.SpawnChildSetupFunc ` +
|
logError(new Error(`Using child GLib.${func} with a GLib.SpawnChildSetupFunc ` +
|
||||||
'is unsafe and may dead-lock, thus it should never be used from JavaScript. ' +
|
'is unsafe and may dead-lock, thus it should never be used from JavaScript. ' +
|
||||||
`Shell.${func} can be used to perform default actions or an ` +
|
`Shell.${func} can be used to perform default actions or an ` +
|
||||||
'async-signal-safe alternative should be used instead'));
|
'async-signal-safe alternative should be used instead'));
|
||||||
|
return originalFunc(...commonArgs, childSetup, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return originalFunc(workingDirectory, argv, envp, flags, childSetup, ...args);
|
const retValue = Shell[`util_${func}`](...commonArgs, ...args);
|
||||||
|
return [true, ...Array.isArray(retValue) ? retValue : [retValue]];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
GLib.spawn_async = wrapSpawnFunction('spawn_async');
|
GLib.spawn_async = wrapSpawnFunction('spawn_async');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user