guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. v2.1.0-97-g22cdf98


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. v2.1.0-97-g22cdf98
Date: Thu, 17 Jan 2013 11:39:10 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=22cdf986db43ea1b81816a1cc0151994d484fdee

The branch, master has been updated
       via  22cdf986db43ea1b81816a1cc0151994d484fdee (commit)
      from  94027fe6ec99874b1f6d1cdf1d7f31f482ecd960 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 22cdf986db43ea1b81816a1cc0151994d484fdee
Author: Andy Wingo <address@hidden>
Date:   Thu Jan 17 12:18:22 2013 +0100

    warning instead of error on multithreaded fork
    
    * libguile/posix.c (scm_fork): Issue a warning instead of an error on a
      multithreaded fork.
    * doc/ref/posix.texi (Processes): Add note about multithreaded fork.

-----------------------------------------------------------------------

Summary of changes:
 doc/ref/posix.texi |   16 +++++++++++++++-
 libguile/posix.c   |    8 ++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 0a688e9..a019f4e 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
 @c Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 2007,
address@hidden   2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
address@hidden   2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, 
Inc.
 @c See the file guile.texi for copying conditions.
 
 @node POSIX
@@ -1785,6 +1785,20 @@ Creates a new ``child'' process by duplicating the 
current ``parent'' process.
 In the child the return value is 0.  In the parent the return value is
 the integer process ID of the child.
 
+Note that it is unsafe to fork a process that has multiple threads
+running, as only the thread that calls @code{primitive-fork} will
+persist in the child.  Any resources that other threads held, such as
+locked mutexes or open file descriptors, are lost.  Indeed,
address@hidden specifies that only async-signal-safe procedures are
+safe to call after a multithreaded fork, which is a very limited set.
+Guile issues a warning if it detects a fork from a multi-threaded
+program.
+
+If you are going to @code{exec} soon after forking, the procedures in
address@hidden(ice-9 popen)} may be useful to you, as they fork and exec within
+an async-signal-safe function carefully written to ensure robust program
+behavior, even in the presence of threads.  @xref{Pipes}, for more.
+
 This procedure has been renamed from @code{fork} to avoid a naming conflict
 with the scsh fork.
 @end deffn
diff --git a/libguile/posix.c b/libguile/posix.c
index 7c87f3f..b9097d4 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -1260,8 +1260,12 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0,
        async-signal-safe.  We can't guarantee that in general.  The best
        we can do is to allow forking only very early, before any call to
        sigaction spawns the signal-handling thread.  */
-    SCM_MISC_ERROR ("attempt to fork while multiple threads are running",
-                    SCM_EOL);
+    scm_display
+      (scm_from_latin1_string
+       ("warning: call to primitive-fork while multiple threads are running;\n"
+        "         further behavior unspecified.  See \"Processes\" in the\n"
+        "         manual, for more information.\n"),
+       scm_current_warning_port ());
   pid = fork ();
   if (pid == -1)
     SCM_SYSERROR;


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]