Skip to content

Conversation

@IanButterworth
Copy link
Member

@IanButterworth IanButterworth commented Jan 9, 2022

Currently ^C-ing a Pkg.test can result in a big mess of mixed-up InterruptException stack traces from the child and parent process, and it's common for the child process to not actually get interrupted given there's only one shot for the ^C to get through to the child before the parent is interrupted and closes the signal forwarding, making it orphaned by the parent and continue to run tests while the parent process tries to go back to the repl, no matter how many times the user ^C's, requiring the user to find the orphaned process and kill it.

This change tries to make the process more graceful:

  • Catches the interrupt in the parent and prints a nicer Pkg message immediately
  • Doesn't show the stacktrace of the interrupted parent process
  • Waits a short while for the child process to exit gracefully, throwing a few more interrupts at it
  • If not exited it then kills the child process cleanly (no signal termination message)
  • Only releases back to the pkg> prompt once the child process is stopped, to avoid the prompt being printed-over

This PR
Screenshot from 2022-01-08 23-58-30

Closes #2922

@IanButterworth
Copy link
Member Author

I think this is a definite UX improvement, but would appreciate a second opinion

@ericphanson
Copy link
Contributor

+1, the current behavior is annoying and feels buggy as a user

@IanButterworth IanButterworth merged commit 0f7167a into JuliaLang:master Jan 17, 2022
@IanButterworth IanButterworth deleted the ib/kill_test_process branch January 17, 2022 06:07
printpkgstyle(ctx.io, :Testing, "Tests interrupted. Exiting the test process\n", color = Base.error_color())
# Give some time for the child interrupt handler to print a stacktrace and exit,
# then kill the process if still running
if timedwait(() -> !process_running(p), 4) == :timed_out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using timedwait is often a general design problem, where you can usually use a Timer(4) and wait(p) instead though

printpkgstyle(ctx.io, :Testing, "Tests interrupted. Exiting the test process\n", color = Base.error_color())
# Give some time for the child interrupt handler to print a stacktrace and exit,
# then kill the process if still running
if timedwait(() -> !process_running(p), 4) == :timed_out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using timedwait is often a general design problem, where you can usually use a Timer(4) and wait(p) instead though

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

Successfully merging this pull request may close these issues.

Interrupting Pkg.test sometimes orphans the test sandbox process

3 participants