Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undisposed instances keep on running forever #8

Open
mkontula opened this issue Feb 25, 2018 · 4 comments
Open

Undisposed instances keep on running forever #8

mkontula opened this issue Feb 25, 2018 · 4 comments

Comments

@mkontula
Copy link

Sometimes when your tests fails, thanks to Visual Studios rock solid (pun-intended) testing runtime, the executable does not get disposed. It would be neat, if we could find a way to kill parentless processes. PowerShell script could run every once in a while in a buildagent VM or redis-inside could use some static shared inventory of started processes. I'd be happy to help with PR if we could first discuss the outlines of the design.

@poulfoged
Copy link
Owner

So I guess even the finalizer does not catch these cases. Would the static inventory work - I mean that is killed as well by Visual Studio right?

How about checking for running process on startup in thread? How would we recognise processes? Could we perhaps tag them with a special argument or something?

Alternatively we could keep a list of processid's somewhere as app-data?

@mkontula
Copy link
Author

Every new instance get's a process named by guid. Prefixing that by something quite obvious shouldn't beetoo hard. Also a static inventory would help keeping track of instances that are still needed (for example parallel test execution scenarios á la xunit.

Another approach is to dig in to VS testing infra. At the time a debug session crashes (like VS does every once in a while) there must be some event that we could hook up. Funny enough, killing denenv.exe process does not kill the rogue instances.

I'm not aware of the exact details, but it would be kinda great if one could wire the child process to be killed when the host process (vstest.host.exe or something similar) is killed?

@poulfoged
Copy link
Owner

Not the best to depend on Visual Studio test infrastructure or specific host processes I think.

Found some alternatives on this SO thread: https://stackoverflow.com/questions/3342941/kill-child-process-when-parent-process-is-killed

So I see three solutions:

  • Create a small fake debugger and attach to Redis.exe (Don't know how this fares with .NET core and permissions).
  • Using job objects (Same problems as above)
  • Create a child process for each Redis instance (in c#) that is signalled when host process dies and carefully kills the Redis process. (I think this could be quite elegant but also requires some work)

@i-e-b
Copy link

i-e-b commented Oct 10, 2018

I have a little NuGet process runner that might help for this:
https://www.nuget.org/packages/RunProcess/

Use like

using (var proc = new ProcessHost("my.exe", @"C:\temp\")) {
    proc.StartAsChild();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants