question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Attaching to already running process

See original GitHub issue

The idea is to extend curent Command.Run API by adding:

public static Command AttachTo(int processId)

which would internally use Process.GetProcessById.

What do you think?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
konrad-kruczynskicommented, Feb 28, 2019

Ok, thanks for all the information, I’ll keep you updated about the progress.

1reaction
konrad-kruczynskicommented, Feb 13, 2019

Having gone through the exercise, there’s actually a decent amount here. What do you think? Am I missing anything? Would this be helpful?

Yes, exactly. For me even having a common API is valuable enough, but resolving all this corner cases is much better.

For consistency, I’m imagining an API like:

public class Command
{
    public static bool TryAttachToProcessId(int processId, out Command command);
}

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:

enum AttachingResult
{
    Success, // obvious
    AttachedWithoutHandle, //  exit code will not be available
    Failure // obvious
}

One open question is what options we should allow for such an API. Many of the options provided for Command.Run don’t make sense in this context, but some (timeout, cancellationToken, throwOnError) DO make sense. Probably we’ll take a separate Action<AttachToProcessOptionsBuilder> for this API.

Good point.

Relatedly, should we add this to the Shell API? Probably for consistency, although likely it wouldn’t be used very often.

Same thoughts.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I attach a terminal to a detached process?
Yes, it is. First, create a pipe: mkfifo /tmp/fifo . Use gdb to attach to the process: gdb -p PID. Then close stdin:...
Read more >
linux - Attach to a processes output for viewing
I think I have a simpler solution here. Just look for a directory whose name corresponds to the PID you are looking for, ......
Read more >
Moving an already-running process to Screen - linux
reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, ......
Read more >
Attach to running processes with the Visual Studio debugger
In Visual Studio, select Debug > Attach to Process (or press Ctrl+Alt+P) to open the Attach to Process dialog box. · Check the...
Read more >
Attaching to a Running Process - GNAT User's Guide
Launch the main program main.exe . $ main · Use the Windows Task Manager to find the process ID. · Launch gdb. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found