From: cyg Simple <cygsimple@gmail.com>
To: cygwin@cygwin.com
Subject: Re: Retrieving per-process environment block?
Date: Tue, 29 Nov 2016 16:01:00 -0000 [thread overview]
Message-ID: <084579a5-19c0-8475-56bb-c0836ef7088f@gmail.com> (raw)
In-Reply-To: <CAOTD34Y9TRq2Qq8Mn2awTf9SCgz0qnbBa-a117pkSEvz9gaHKQ@mail.gmail.com>
On 11/29/2016 8:26 AM, Erik Bray wrote:
> On Thu, Nov 17, 2016 at 3:00 PM, Corinna Vinschen
> <corinna-cygwin@cygwin.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
next prev parent reply other threads:[~2016-11-29 14:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-17 18:05 Erik Bray
2016-11-17 18:11 ` Corinna Vinschen
2016-11-29 15:28 ` Erik Bray
2016-11-29 16:01 ` cyg Simple [this message]
2016-11-30 11:03 ` Corinna Vinschen
2016-11-29 16:35 ` Eliot Moss
2016-11-29 17:42 ` Erik Bray
2016-11-29 18:02 ` Andrey Repin
2016-11-30 4:28 ` Herbert Stocker
2016-11-30 10:43 ` Eliot Moss
2016-11-30 10:47 ` Peter Rosin
2016-11-30 10:47 ` Erik Bray
2016-11-30 12:29 ` Corinna Vinschen
2016-11-30 12:36 ` Corinna Vinschen
2016-11-30 11:36 ` Corinna Vinschen
2016-11-30 11:06 ` Corinna Vinschen
2016-11-30 10:48 ` Corinna Vinschen
2016-11-30 14:49 ` Erik Bray
2016-11-30 15:04 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=084579a5-19c0-8475-56bb-c0836ef7088f@gmail.com \
--to=cygsimple@gmail.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).