From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] Implement open-process and related functions on MinGW Date: Sat, 22 Feb 2014 17:02:35 -0500 Message-ID: <87mwhikdqc.fsf@yeeloong.lan> References: <834n3x8o7m.fsf@gnu.org> <83y519788a.fsf@gnu.org> <871tz0d5vc.fsf@gnu.org> <83iosc76kz.fsf@gnu.org> <87vbwc72dp.fsf_-_@gnu.org> <8361o74e0k.fsf@gnu.org> <87zjljjg7r.fsf@yeeloong.lan> <83eh2v2em9.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1393106623 19730 80.91.229.3 (22 Feb 2014 22:03:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Feb 2014 22:03:43 +0000 (UTC) Cc: ludo@gnu.org, guile-devel@gnu.org To: Eli Zaretskii Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Feb 22 23:03:52 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WHKfo-00013r-3F for guile-devel@m.gmane.org; Sat, 22 Feb 2014 23:03:52 +0100 Original-Received: from localhost ([::1]:50989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHKfn-0003nj-KT for guile-devel@m.gmane.org; Sat, 22 Feb 2014 17:03:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHKfh-0003nU-5Q for guile-devel@gnu.org; Sat, 22 Feb 2014 17:03:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WHKfc-0005Gx-Eb for guile-devel@gnu.org; Sat, 22 Feb 2014 17:03:45 -0500 Original-Received: from world.peace.net ([96.39.62.75]:48945) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHKfc-0005Gt-At; Sat, 22 Feb 2014 17:03:40 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong.lan) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1WHKfT-00016U-PR; Sat, 22 Feb 2014 17:03:31 -0500 In-Reply-To: <83eh2v2em9.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 22 Feb 2014 20:20:46 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16920 Archived-At: Eli Zaretskii writes: >> From: Mark H Weaver >> Cc: ludo@gnu.org (Ludovic Court=C3=A8s), guile-devel@gnu.org >> Date: Sat, 22 Feb 2014 10:54:16 -0500 >>=20 >> Thanks for working on this, but in a multithreaded program, it's no good >> to change the file descriptors in the main program temporarily before >> spawning, and then restore them afterwards. We'll have to find another >> way of doing this. > > Btw, how does the Posix build work reliably when it forks after > several threads are already running? I don't see any calls to > pthread_atfork or any similar machinery in place. What am I missing? It's safe to fork a multithreaded program without using pthread_atfork if only async-signal-safe functions are called before the exec. In fact, that's why Andy rewrote 'open-process' in C, as it says in the comment above that function. "If a multi-threaded process calls fork(), the new process shall contain a replica of the calling thread and its entire address space, possibly including the states of mutexes and other resources. Consequently, to avoid errors, the child process may only execute async-signal-safe operations until such time as one of the exec functions is called." http://pubs.opengroup.org/onlinepubs/000095399/functions/fork.html Mark