delve icon indicating copy to clipboard operation
delve copied to clipboard

Exit from attached process without prompt

Open mkasner opened this issue 3 years ago • 11 comments

When using dlv attach to debug local running process, it's really annoying to answer the prompt Would you like to kill the process? [Y/n] It slows the debugging flow a lot and this question is not something critical when debugging a local process.

I propose that config param is introduced which could set allow user that prefers not to kill running process. Already did some implementation which introduces config param soft-detach: true If param is true it will skip the yesno question, and will exit from dlv without killing the process.

If this is something that could be useful, I can submit PR request, but wanted to discuss this enhancement here first.

mkasner avatar Jan 25 '21 07:01 mkasner

I'm skeptical that pressing two keys "slows the debugging flow a lot"

aarzilli avatar Jan 25 '21 11:01 aarzilli

:) maybe 'a lot' is a too strong word, I agree.

Since I'm always answering the same answer to yesno question, I wanted to find a way to automate it.

If this is not interesting enhancement, you can close the issue. I'm going to use that in my flow.

mkasner avatar Jan 26 '21 08:01 mkasner

I think it would be reasonable to add arguments to the exit command that control what it does instead of asking the user, and it would also be reasonable to extend the alias mechanism config alias... to allow defining an alias to a command+arguments. Adding an option just for this does too little.

aarzilli avatar Jan 26 '21 16:01 aarzilli

Is it OK to reuse the same exit -c argument to exit without prompt? It's different client, so it won't conflict with current usage of exit -c.

Then I would look how to extend alias mechanism to allow command+arguments.

mkasner avatar Jan 29 '21 06:01 mkasner

It would be ambiguous, when connected to a headless instance attached to a process would exit -c mean "disconnect, terminate headless instance, detach from process (without killing)" or "disconnect, keep headless instance running, resume attached process"

aarzilli avatar Jan 29 '21 08:01 aarzilli

So then new argument should be implemented, if this one is ambiguous. Which one would be appropriate? Maybe exit -d (as detach)

mkasner avatar Feb 05 '21 05:02 mkasner

Hi, I have another use-case for something like this.

Im currently automating the deployment of a daemonised application in "debug mode", where it runs as normal, but is wrapped in a headless delve server which allows clients to connect debug clients remotely.

Directly after starting the headless server (as part of an automated script), I want my application (the daemon) to immediately begin executing like it normally would, so after I call dlv --headless exec mydaemon, I immediately auto-connect a debug client with an init file, which just says:

continue
exit

However, because the client requires human input (y), that automated client actually cannot kill itself (I need to instead kill the process) with kill.

I'd be very much in favour of a -y flag similar to what pkg managers like apt and yum offer, which automatically say "yes" (or "no") to any anti-automation prompts like this. I'd be very happy to PR this feature if you'd be happy to accept it! :) let me know

aaaaaaaalex avatar Jul 02 '21 12:07 aaaaaaaalex

Hi, I have another use-case for something like this.

Im currently automating the deployment of a daemonised application in "debug mode", where it runs as normal, but is wrapped in a headless delve server which allows clients to connect debug clients remotely.

Directly after starting the headless server (as part of an automated script), I want my application (the daemon) to immediately begin executing like it normally would, so after I call dlv --headless exec mydaemon, I immediately auto-connect a debug client with an init file, which just says:

continue
exit

However, because the client requires human input (y), that automated client actually cannot kill itself (I need to instead kill the process) with kill.

I'd be very much in favour of a -y flag similar to what pkg managers like apt and yum offer, which automatically say "yes" (or "no") to any anti-automation prompts like this. I'd be very happy to PR this feature if you'd be happy to accept it! :) let me know

If I understand correctly your use case can be solved already via dlv debug --headless --continue which will accomplish what your init script does but without the headache you mention.

derekparker avatar Jan 28 '22 22:01 derekparker

I would most likely accept a patch which implements this feature if folks feel strongly enough about it.

derekparker avatar Jan 28 '22 22:01 derekparker

(Sorry, clicked wrong button and did not mean to close).

derekparker avatar Jan 28 '22 22:01 derekparker

Hi I would like this feature too. I'd like to write a script that automates generating a list of functions for me. Something like:

gen-funcs.dlv

transcript -x funcs.out
funcs
exit -y

And then I can attach to the binary and do

dlv source gen-funcs.dlv

johnsaigle avatar Jul 25 '22 15:07 johnsaigle