Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gdesktopappinfo: enable fast posix_spawn gspawn codepath
In order to use the new posix_spawn gspawn codepath, for more robust app launching when available memory is low, we need to meet some conditions. child_setup needs to be NULL for this optimization to work, so drop the internal child_setup that is used here. Replace it with a lightweight wrapper binary (gio-launch-desktop) that sets GIO_LAUNCHED_DESKTOP_FILE_PID before executing the app. Adjust PATH for gio tests so that it can execute the new binary from the build directory.
- Loading branch information
Showing
6 changed files
with
106 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* GIO - GLib Input, Output and Streaming Library | ||
* | ||
* Copyright (C) 2018 Endless Mobile, Inc. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General | ||
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Author: Daniel Drake <drake@endlessm.com> | ||
*/ | ||
|
||
/* | ||
* gio-launch-desktop: GDesktopAppInfo helper | ||
* Executable wrapper to set GIO_LAUNCHED_DESKTOP_FILE_PID | ||
* There are complications when doing this in a fork()/exec() codepath, | ||
* and it cannot otherwise be done with posix_spawn(). | ||
* This wrapper is designed to be minimal and lightweight. | ||
* It does not even link against glib. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
int | ||
main (int argc, char *argv[]) | ||
{ | ||
pid_t pid = getpid (); | ||
char buf[50]; | ||
int r; | ||
|
||
if (argc < 2) | ||
return -1; | ||
|
||
r = snprintf (buf, sizeof (buf), "GIO_LAUNCHED_DESKTOP_FILE_PID=%ld", (long) pid); | ||
if (r >= sizeof (buf)) | ||
return -1; | ||
|
||
putenv (buf); | ||
|
||
return execvp (argv[1], argv + 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters