Code Monkey home page Code Monkey logo

gapotchenko.fx's People

Contributors

egubenya avatar hrumhurum avatar kevingosse avatar kolos450 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gapotchenko.fx's Issues

Won't get current environment variables values on Linux

File.OpenRead(GetProcEntryFilePath(process.Id, "environ")),

This is correct for getting the environment variables of the process when it was started, but not for getting the actual current state.

gdb is able to do this: start bash in one terminal, echo $$ to get its PID, then sudo gdb --pid=<PID> to launch gdb. Then just do p environ[0] and it will give you the first environment variable.

It may be possible to use libc's ptrace to coerce the environment variables from a running process, but there is a security restriction in that ptrace will fail on any other process unless you run it as root, or you started it with fork(). I don't know if Process.Start() uses fork() internally.

There is a fairly detailed discussion about it here:
https://unix.stackexchange.com/questions/29128/how-to-read-environment-variables-of-a-process

Don't feel compelled by the notion of shelling to gdb if it's available: sibling processes cannot access one another.

Process.ReadEnvironmentVariables() sometimes causes System.IO.EndOfStreamException : Attempted to read past the end of the stream.

I am getting the following exception

Message: System.IO.EndOfStreamException : Attempted to read past the end of the stream. Stack Trace: ProcessBinaryReader.ReadCString() ProcessEnvironment._ReadEnv(ProcessBinaryReader br) ProcessEnvironment._ReadVariablesCore(IntPtr hProcess) ProcessEnvironment.ReadVariables(Process process) ImplementationAdapter.ReadProcessEnvironmentVariables(Process process) ProcessExtensions.ReadEnvironmentVariables(Process process)

From my code:

var oldProcesses = Process.GetProcesses() .Where(x => x.ProcessName.Contains("dotnet")) && x.ReadEnvironmentVariables().ContainsKey("...")).ToList();

I am using version 2020.1.15 of the nuget package. I only see the error occasionally, I have tried to find something that distinguishes the errored process from other processes and have to yet find anything.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.