1. 13 Jul, 2018 1 commit
  2. 29 Jun, 2018 1 commit
  3. 25 Jun, 2018 1 commit
  4. 23 Jun, 2018 1 commit
    • Ting-Wei Lan's avatar
      gspawn: Declare environ · e14c853d
      Ting-Wei Lan authored
      Function do_posix_spawn uses environ, but gspawn.c doesn't declare it.
      Since there is no system header declaring this global variable, this
      causes compilation error on FreeBSD.
      
      Code added in this commit is copied from genviron.c.
      e14c853d
  5. 21 Jun, 2018 4 commits
    • Daniel Drake's avatar
      gspawn: use sane_open() for stdin · 2b560457
      Daniel Drake authored
      sane_open() is used for stdout and stderr, but regular open() was being
      used for stdin. Spotted by Philip Withnall.
      2b560457
    • Daniel Drake's avatar
      gspawn: document FD_CLOEXEC behaviour · 86e2b8d4
      Daniel Drake authored
      G_SPAWN_LEAVE_DESCRIPTORS_OPEN must be set to enable the optimized
      posix_spawn codepath, so this flag is likely to see more usage now.
      
      Document that FD_CLOEXEC can be used to cause file descriptors to be
      automatically closed while this flag is used.
      86e2b8d4
    • Daniel Drake's avatar
      gspawn: Optimize with posix_spawn codepath · 61f54591
      Daniel Drake authored
      When the amount of free memory on the system is somewhat low, gnome-shell
      will sometimes fail to launch apps, reporting the error:
        fork(): Cannot allocate memory
      
      fork() is failing here because while cloning the process virtual address
      space, Linux worries that the thread being forked may end up COWing the
      entire address space of the parent process (gnome-shell, which is
      memory-hungry), and there is not enough free memory to permit that to
      happen.
      
      In this case we are simply calling fork() in order to quickly call exec(),
      which will throw away the entirity of the duplicated VM, so we should
      look for ways to avoid the overcommit check.
      
      The well known solution to this is to use clone(CLONE_VM) or vfork(), which
      completely avoids creating a new memory address space for the child.
      However, that comes with a bunch of caveats and complications:
      
        https://gist.github.com/nicowilliams/a8a07b0fc75df05f684c23c18d7db234
        https://ewontfix.com/7/
      
      In 2016, glibc's posix_spawn() was rewritten to use this approach
      while also resolving the concerns.
      https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9ff72da471a509a8c19791efe469f47fa6977410
      
      I experimented with a similar approach in glib, but it was not practical
      because glibc has several items of important internal knowledge (such as
      knowing which signals should be given special treatment because they are
      NPTL implementation details) that are not cleanly exposed elsewhere.
      
      Instead, this patch adapts the gspawn code to use posix_spawn() where
      possible, which will reap the benefits of that implementation.
      The posix_spawn API is more limited than the gspawn API though,
      partly due to natural limitations of using CLONE_VM, so the posix_spawn
      path is added as a separate codepath which is only executed when the
      conditions are right. Callers such as gnome-shell will have to be modified
      to meet these conditions, such as not having a child_setup function.
      
      In addition to allowing for the gnome-shell "Cannot allocate memory"
      failure to be avoided, this should result in a general speedup in this
      area, because fork()'s behaviour of cloning the entire VM space
      has a cost which is now avoided. posix_spawn() has also recently
      been optimized on OpenSolaris as the most performant way to spawn
      a child process.
      61f54591
    • Daniel Drake's avatar
      gspawn: Add g_spawn_async_with_fds variant · 3524de16
      Daniel Drake authored
      Add a new process spawning function variant which allows the caller
      to pass specific file descriptors for stdin, stdout and stderr.
      It is otherwise identical to g_spawn_async_with_pipes.
      
      Allow the same fd to be passed in multiple parameters. To make this
      workable, the child process logic that closes the fd after the first time
      it has been dup2'ed needed tweaking; we now just set those fds to be
      closed upon exec using the CLOEXEC flag. Add a test for this case.
      
      This will be used by gnome-shell to avoid performing equivalent
      dup2 actions in a child_setup function. Dropping use of child_setup will
      enable use of an upcoming optimized process spawning codepath.
      3524de16
  6. 12 Jun, 2018 1 commit
  7. 08 Feb, 2018 1 commit
  8. 07 Nov, 2017 1 commit
  9. 26 Oct, 2017 1 commit
  10. 12 Oct, 2017 1 commit
  11. 03 Aug, 2017 1 commit
  12. 24 May, 2017 1 commit
    • Sébastien Wilmet's avatar
      glib/: LGPLv2+ -> LGPLv2.1+ · f9faac76
      Sébastien Wilmet authored
      All glib/*.{c,h} files have been processed, as well as gtester-report.
      
      12 of those files are not licensed under LGPL:
      
      	gbsearcharray.h
      	gconstructor.h
      	glibintl.h
      	gmirroringtable.h
      	gscripttable.h
      	gtranslit-data.h
      	gunibreak.h
      	gunichartables.h
      	gunicomp.h
      	gunidecomp.h
      	valgrind.h
      	win_iconv.c
      
      Some of them are generated files, some are licensed under a BSD-style
      license and win_iconv.c is in the public domain.
      
      Sub-directories inside glib/:
      
      	deprecated/: processed in a previous commit
      	glib-mirroring-tab/: already LGPLv2.1+
      	gnulib/: not modified, the code is copied from gnulib
      	libcharset/: a copy
      	pcre/: a copy
      	tests/: processed in a previous commit
      
      https://bugzilla.gnome.org/show_bug.cgi?id=776504
      f9faac76
  13. 30 Apr, 2017 1 commit
  14. 04 Jan, 2017 1 commit
  15. 22 Nov, 2016 1 commit
  16. 12 Oct, 2016 1 commit
  17. 07 Jun, 2016 1 commit
  18. 04 Jun, 2016 1 commit
  19. 23 Jul, 2015 1 commit
  20. 31 May, 2014 1 commit
  21. 20 Feb, 2014 1 commit
  22. 06 Feb, 2014 2 commits
  23. 31 Jan, 2014 1 commit
  24. 17 Oct, 2013 1 commit
  25. 01 Jul, 2013 2 commits
  26. 21 May, 2013 1 commit
    • Dan Winship's avatar
      Use 'dumb quotes' rather than `really dumb quotes' · 4b94c083
      Dan Winship authored
      Back in the far-off twentieth century, it was normal on unix
      workstations for U+0060 GRAVE ACCENT to be drawn as "‛" and for U+0027
      APOSTROPHE to be drawn as "’". This led to the convention of using
      them as poor-man's ‛smart quotes’ in ASCII-only text.
      
      However, "'" is now universally drawn as a vertical line, and "`" at a
      45-degree angle, making them an `odd couple' when used together.
      
      Unfortunately, there are lots of very old strings in glib, and also
      lots of new strings in which people have kept up the old tradition,
      perhaps entirely unaware that it used to not look stupid.
      
      Fix this by just using 'dumb quotes' everywhere.
      
      https://bugzilla.gnome.org/show_bug.cgi?id=700746
      4b94c083
  27. 23 Apr, 2013 1 commit
  28. 29 Jan, 2013 1 commit
    • Colin Walters's avatar
      Add g_close(), use it · f398bec5
      Colin Walters authored
      There are two benefits to this:
      
      1) We can centralize any operating system specific knowledge of
         close-vs-EINTR handling.  For example, while on Linux we should never
         retry, if someone cared enough later about HP-UX, they could come by
         and change this one spot.
      2) For places that do care about the return value and want to provide
         the caller with a GError, this function makes it convenient to do so.
      
      Note that gspawn.c had an incorrect EINTR loop-retry around close().
      
      https://bugzilla.gnome.org/show_bug.cgi?id=682819
      f398bec5
  29. 15 Nov, 2012 1 commit
  30. 14 Nov, 2012 1 commit
  31. 02 Nov, 2012 1 commit
    • Colin Walters's avatar
      Merge waitpid() from g_spawn_sync into gmain() · ce002293
      Colin Walters authored
      This is preparatory work for a future commit which will add a
      "catchall" waitpid API.  If we don't synchronize here with the worker
      thread, race conditions are possible.
      
      This also ensures we have an error message if someone adds a child
      watch for a nonexistent pid, etc.  Previously, we'd simply keep
      calling waitpid() getting ECHILD, and ignoring it until the source was
      removed. Now, we g_warning() and fire the source.
      
      Thirdly, this ensures that the waitpid() call in gmain handles EINTR,
      like the g_spawn_sync() one did.
      
      https://bugzilla.gnome.org/show_bug.cgi?id=687061
      ce002293
  32. 29 Oct, 2012 1 commit
    • Paul Eggert's avatar
      gmain: Document constraints on waitpid · 00f4c12b
      Paul Eggert authored
      Applications that use glib should not invoke waitpid with a first
      argument that is nonpositive, because when such a waitpid is run in
      one thread and glib waits for a subprocess in another, there is a race
      condition, and the former waitpid can reap a process that was intended
      for the latter.  Mention this in the documentation for
      g_child_watch_source_new, and in the diagnostic generated by
      g_spawn_sync when its waitpid fails with errno equal to ECHILD.
      Signed-off-by: Colin Walters's avatarColin Walters <walters@verbum.org>
      
      http://bugzilla.gnome.org/show_bug.cgi?id=687075
      00f4c12b
  33. 28 Aug, 2012 3 commits