delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/11/29/08:26:35

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; q=dns; s=default; b=ZGJiT+0
oV9yQ7sno3nmVunfa/Q3keibZ2qNsY8JoG/45vjAUnbiTniYZZagaUdWvTmDAU1F
pGLWUXZl1CCgrZzy9SNnsud/Gt7GhXARVINGSkBT8uTwlILVj2aSJvp2loqCtuks
2ZZqeXYTxhFMU7XHFb0uX5qeP/gf/9+umbls=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; s=default; bh=/HKjESGzqg2LV
iUrIdztM7AJKYw=; b=DyKFcMsJS3f9STKZT0eZXoEWrNAk+XKwR/io+lXPbynnc
mTTZ/mLGoY23a5OgMZ0WkN5AqlFdAXMHHpUDliBdylnhBXCo443t3vCBngvwDvfJ
xLXb+kWnxdoHB/EWX53XRFE7VXoArjeetfQEGWYvuPGFM8RF7OjpVY4IYrz/W8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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
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
In-Reply-To: <20161117140012.GA23664@calimero.vinschen.de>
References: <CAOTD34ZFH5E3r3AuDOXctss46e1hoU2f9pwE1mt4L674J2Ak_A AT mail DOT gmail DOT com> <20161117140012 DOT GA23664 AT calimero DOT vinschen DOT de>
From: Erik Bray <erik DOT m DOT bray AT gmail DOT com>
Date: Tue, 29 Nov 2016 14:26:03 +0100
Message-ID: <CAOTD34Y9TRq2Qq8Mn2awTf9SCgz0qnbBa-a117pkSEvz9gaHKQ@mail.gmail.com>
Subject: Re: Retrieving per-process environment block?
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

On Thu, Nov 17, 2016 at 3:00 PM, Corinna Vinschen
<corinna-cygwin AT cygwin DOT com> 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/<pid>/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/<pid>/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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019