From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 705 invoked by alias); 29 Nov 2016 13:26:18 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 130724 invoked by uid 89); 29 Nov 2016 13:26:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=route, Hx-languages-length:2075, implications, U*corinna-cygwin X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Nov 2016 13:26:06 +0000 Received: by mail-wm0-f43.google.com with SMTP id t79so187417263wmt.0 for ; Tue, 29 Nov 2016 05:26:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=6fpeFhINtjWbs4PdRXu0pc7q/IZUB9fJG/q2xRbGjAU=; b=mN5/LdXZuh/mIG1rrfk2pxunmHO9kzgHC9K4rUXJgnOwlOxvSbP/nJ47dIXPFUCl34 UugNlVHimpqttERPr9aA6rT9S4j+1sGJVJGAP243ZI50MgZlKAeZYkYB0yHrHLgzWST5 XShN2nZGbZvJmZXKicjt33dRTCHRoLaganwUoX06zYDiu826wqZgFEBizZiAjauGHIlg H8tukijSwWcOe3Zkp7SV1ai2hGAp5d6BSeyP2l5Okmlj8FK+Bjzpfl+GQODW0dWQ7Sr3 uTvTZoOKk6P128im6uzSK6ohbf7bwrvp0eRQrPnJYr2/wn1r9qBEmCBoYYMj1kphBTcq Dc+Q== X-Gm-Message-State: AKaTC01H00t0PeAz4XscFRyZcL0VzC1sdPl92xXyLGKZF1zt7TfFmZYyErfe2P5yNLL+VmBuzY4KJbRiv96jMQ== X-Received: by 10.28.6.147 with SMTP id 141mr25486369wmg.98.1480425964073; Tue, 29 Nov 2016 05:26:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.151.46 with HTTP; Tue, 29 Nov 2016 05:26:03 -0800 (PST) In-Reply-To: <20161117140012.GA23664@calimero.vinschen.de> References: <20161117140012.GA23664@calimero.vinschen.de> From: Erik Bray Date: Tue, 29 Nov 2016 15:28:00 -0000 Message-ID: Subject: Re: Retrieving per-process environment block? To: cygwin@cygwin.com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00322.txt.bz2 On Thu, Nov 17, 2016 at 3:00 PM, Corinna Vinschen wrote: > On Nov 17 14:30, Erik Bray wrote: >> Hi all, >> >> For a quick bit of background, I'm working on porting the highly >> useful psutil [1] Python library to Cygwin. This has proved an >> interesting exercise, as much of the functionality of psutil works on >> Cygwin through existing POSIX interfaces, and a handful of >> Linux-specific interfaces as well. But there are some bits that >> simply don't map at all. >> >> The one I'm struggling with right now is retrieving Cygwin environment >> variables for a process (under inspection--i.e. not listing a >> process's environment from within that process which is obviously >> trivial). >> >> I've looked at every route I could conceive of but as far as I can >> tell this is currently impossible. That's fine for now--I simply >> disable that functionality in psutil. But it is unfortunate, though, >> since the information is there. >> >> There are a couple avenues I could see to this. The most "obvious" >> (to me) being to implement /proc//environ. >> >> I would be willing to provide a patch for this if it would be >> accepted. Is there some particular non-obvious hurdle to this that it >> hasn't been implemented? Obviously there are security >> implications--the /proc//environ should only be readable to the >> process's owner, but that is already within Cygwin's capabilities, and >> works for other /proc files. > > Patch welcome. Implementing this should be fairly straightforward. > The only hurdle is winsup/CONTRIBUTORS ;) Thanks--I went to go work on this finally but it turns out not to be straightforward after all, as the process's environment is not shared in any way between processes. I could do this, if each process kept a copy of its environment block in shared memory, which would in turn have to be updated every time the process's environment is updated. But I don't know what the impact of that would be performance-wise. Any advice? Thanks, Erik -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple