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

Exit from attached process without prompt #2324

Open
mkasner opened this issue Jan 25, 2021 · 11 comments
Open

Exit from attached process without prompt #2324

mkasner opened this issue Jan 25, 2021 · 11 comments

Comments

@mkasner
Copy link

mkasner commented Jan 25, 2021

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.

@aarzilli
Copy link
Member

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

@mkasner
Copy link
Author

mkasner commented Jan 26, 2021

:) 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.

@aarzilli
Copy link
Member

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.

@mkasner
Copy link
Author

mkasner commented Jan 29, 2021

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.

@aarzilli
Copy link
Member

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"

@mkasner
Copy link
Author

mkasner commented Feb 5, 2021

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

@aaaaaaaalex
Copy link

aaaaaaaalex commented Jul 2, 2021

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

@derekparker
Copy link
Member

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
Copy link
Member

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

@derekparker
Copy link
Member

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

@johnsaigle
Copy link

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

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

No branches or pull requests

5 participants