-
Notifications
You must be signed in to change notification settings - Fork 32
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
Attaching to already running process #30
Comments
@konrad-kruczynski thanks for your suggestion! It would be helpful to me to be able to understand your use-case a bit better. One of the reasons I've held off creating an API like this so far is because, to my knowledge, you can't use the standard IO streams of a process fetched with GetProcessById(). For example:
What would you be trying to do with this API and would it work given that restriction (and potentially others)? |
Indeed you can't redirect input/output, but operations like killing, getting priority, waiting for exit are still possible. My use case briefly:
Having this in MedallionShell would allow me to use common API for both. |
I'd also like to check for the exit code of the attached process which is also possible if you access its |
Thanks @konrad-kruczynski . This is making me think about what value MedallionShell will add on top of the base
Having gone through the exercise, there's actually a decent amount here. What do you think? Am I missing anything? Would this be helpful? For consistency, I'm imagining an API like:
The reason I want this to be a Try operation is that in the case where the process does not exist, or exits before we can grab the safe handle, we can't really return a functional One open question is what options we should allow for such an API. Many of the options provided for Relatedly, should we add this to the Thoughts? |
Yes, exactly. For me even having a common API is valuable enough, but resolving all this corner cases is much better.
Although in my initial proposition I proposed different version, just a little bit later I've realized that the try version would be the best option, so you've actually taken words from my mouth. One could also think to return enum instead of bool with possible values:
Good point.
Same thoughts. |
Thanks @konrad-kruczynski . I think this makes sense to add as part of the next release. Let me know if this is a feature you would be interested in contributing and I can provide some guidance on that front. Otherwise, I'll work on this in the next month or so. |
I think I would be able to work on this in March. What do you think? |
@konrad-kruczynski sounds great! Based on our previous discussion, here's where I think we should end up API-wise:
Some notes:
For implementation, I think the best route will be to introduce a new internal class which derives from As far as tests to add, it will be tricky to test every single possible race condition but I think that's ok. At minimum we should test:
When you're ready to file a pull request, please target the |
Ok, thanks for all the information, I'll keep you updated about the progress. |
I have finally started working on this. Stub of the work can be seen here: https://github.com/konrad-kruczynski/MedallionShell/tree/attached_command Nothing actually interesting, maybe apart from the fact that .NET 4.5 does not have Now, however, with |
Thanks!
Interesting. It does make me a bit worried since Also, while investigating this I ran into the fact that sometimes accessing the handle will throw
Moving these to an internal static |
However .NET 4.6/4.7 users can target .NET Standard 1.3, is that right? Different question is if they will ;)
I've tested it on Debian, and it didn't show up (not running as root), so probably it's not a problem there. I can later test it on MacOS.
Good point, I'll do that.
OK. |
Since I have added a pull request, I think that we can close the issue and start the review process, maybe moving some part of the discussion there. What do you think? |
@konrad-kruczynski now that the PR is linked to the issue I think the issue will close automatically when the PR is complete. Agreed that further discussion should happen on the PR |
FYI @konrad-kruczynski I just published version 1.6 to NuGet. Apologies for the long delay; I was trying to bundle in some other improvements in the release which took longer than expected. |
The delay was actually not a problem, in fact now is the time I'll start using the new feature. Thanks for the whole patch process, it (cooperation) was a pleasure. |
The idea is to extend curent
Command.Run
API by adding:which would internally use
Process.GetProcessById
.What do you think?
The text was updated successfully, but these errors were encountered: