Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'elif': 0.05; 'subject:file': 0.07; '22,': 0.09; 'default.': 0.09; 'cc:addr :python-list': 0.11; 'windows': 0.15; 'caveats': 0.16; 'cloexec': 0.16; 'fds': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'optional': 0.16; 'subject:skip:m 10': 0.16; 'two.': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'passing': 0.19; 'preferred': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'changes,': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'unix': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'default,': 0.31; 'run': 0.32; 'url:python': 0.33; 'implemented': 0.33; 'received:google.com': 0.35; 'there': 0.35; 'url:org': 0.36; 'depends': 0.38; 'url:library': 0.38; 'needed': 0.38; 'pm,': 0.38; 'anything': 0.39; 'recent': 0.39; 'though,': 0.39; 'url:3': 0.61; 'course': 0.61; 'making': 0.63; 'here': 0.66; 'between': 0.67; 'mar': 0.68; 'study': 0.69; 'environment;': 0.84; 'subject:handle': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=xx+LDHS3OCNLyQFsVpVb/xBNzH+hsEkm/1mkAB53bzc=; b=O5Dn4NivfAiBgOhaYdkRKNIE5FPX2sphpzDs1V37EioPnhmK50gmjjaNwcmaT9Vezq WtkGhktEb65mKn28g7ymsaihFhLQKSvxu7oF1qQ3KIKoeV3qWko7E0b4U8Amj2Fmjmqw fbMuSzExSGBeFVjdUN6JfGXDi82BIHhDd+c3/vZ6s3zr6gJBvpSkFRXZmVK2pdD7wo/d RCPFayv3hXib/y1DRbE+yOGCi1rvvAcS8sIHwYO5FZkDV57gEoLsmYZ45DfbmclSvujF 1UIXGR9AJSlI1rlhKrsodQ8uoP0M/ClNwXnoCKfHOhyuK7pOsRFb6oWmW7kWLh7nS/Ms mXww== MIME-Version: 1.0 X-Received: by 10.66.142.233 with SMTP id rz9mr57036068pab.71.1395442207244; Fri, 21 Mar 2014 15:50:07 -0700 (PDT) In-Reply-To: References: <878us35tz8.fsf@elektro.pacujo.net> Date: Sat, 22 Mar 2014 09:50:07 +1100 Subject: Re: Implement multiprocessing without inheriting parent file handle From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395442211 news.xs4all.nl 2912 [2001:888:2000:d::a6]:45834 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68727 On Sat, Mar 22, 2014 at 5:16 AM, Mark H Harris wrote: > On 3/21/14 12:42 PM, Marko Rauhamaa wrote: >> >> http://docs.python.org/3/library/subprocess.html#popen-constructor> > > >> It's got the optional close_fds parameter, which is True by default. > > >> IOW, you don't need to do anything if you use subprocess.Popen() to >> start your child process. Incidentally, that's the preferred way. > > > hi Marko, of course this depends on the environment; if unix-like, then yes, > elif windows well, not so much... > > There are caveats about stdin, stdout, and stderr; as well, there are > caveats about passing fds between the two. Well, Popen() is implemented on > unix and windows differently, so there is some study needed here if code is > going to be run in both environments. There were some recent changes, though, including making CLOEXEC the default, which means that fork/exec on Unix will retain only the fds you actually want. ChrisA