delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/11/29/09:12:23

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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=woLSfSn5tmgb0MyW
1F1sSazHxu3mrXI/w2Tkaa5wr2FUz4R8yx2WsDIOVEwxQSo58wsgcpRLyv4jyDEW
GAQGP/96mjWHDV5Q70+nHPvcJKH5bGQ8fodKrkmE+rL8w9Tv8N7kMMgy+uWK9jju
X85XsHFX75KelwqFXqrR/4fImBk=
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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=YbGO9KvkyxDvsLhkUO3G1P
shJSQ=; b=lvFkVqXouPE0rl8NRsj4Xqx6jF6lSXNjmZAqO28+6ttr6VZAC9oGdj
nJXVaJ3t8lgG7oH0tkNL8zNyMXVwZDKMeq/liHp9+L5NBuNQaB7Ys62UcvWeni5/
RI8r0u3lIjH/MJIs6XXXOpsGwRjrfNt2ylqbhGwvaBTXQ2/1ljpoU=
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.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=wake, H*i:sk:CAOTD34, H*r:ip*192.168.0.6, highly
X-HELO: mail-io0-f170.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=5RsXaufsKkL19q6MagPtUZVwQqoMSJSCYgN1BVIDTnY=; b=V7VXMJzgOqA2d++c/K9unLuC9rl/Q73Z2ZN3v/GQM+PlfGNj9CTrVMA4S3NQwiORHs l6k4JTJgGIS+JICBTikgfXCqOpyg5gX6JyLQMRJDIPQkq+Z0KnKH35YT5yA9ht+KyhnE iRqsYZLpX00YziUnzz04u3cQZaNrHfszsq7j9m5sayWbC9fjUOtivd6kkuGD7gvnFp4l 6dlIpM+ClDM1OBCghDoSKDbJ+BA0ZoIZ+u5BWMyipbeb1OwsIVr017gLX3PUsYBazxx5 9LgLtEZbOglpYD5043QGGwGpNt2WyMr64T4Os+hB2/CPaZaz5Ezgk3eEcF5Ly36RCvvn perg==
X-Gm-Message-State: AKaTC01dv7ZCG0+7DJKexMGxydVlcmkMdmGh75DQjZuD+iV0mSFL2frKNSckyistGyr5iw==
X-Received: by 10.36.200.10 with SMTP id w10mr23358192itf.21.1480428718209; Tue, 29 Nov 2016 06:11:58 -0800 (PST)
Subject: Re: Retrieving per-process environment block?
To: cygwin AT cygwin DOT com
References: <CAOTD34ZFH5E3r3AuDOXctss46e1hoU2f9pwE1mt4L674J2Ak_A AT mail DOT gmail DOT com> <20161117140012 DOT GA23664 AT calimero DOT vinschen DOT de> <CAOTD34Y9TRq2Qq8Mn2awTf9SCgz0qnbBa-a117pkSEvz9gaHKQ AT mail DOT gmail DOT com>
From: cyg Simple <cygsimple AT gmail DOT com>
Message-ID: <084579a5-19c0-8475-56bb-c0836ef7088f@gmail.com>
Date: Tue, 29 Nov 2016 09:11:38 -0500
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0
MIME-Version: 1.0
In-Reply-To: <CAOTD34Y9TRq2Qq8Mn2awTf9SCgz0qnbBa-a117pkSEvz9gaHKQ@mail.gmail.com>
X-IsSubscribed: yes

On 11/29/2016 8:26 AM, Erik Bray wrote:
> 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?
> 

Sounds like a job for a thread that wakes every X time units to check
the contents of the environment.  Or is there a notification API that
could be used to wake the thread?  I know there is a disk change
notification API for this; maybe one for environment changes as well.

-- 
cyg Simple

--
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