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

Add the ability to send a signal to a subprocess #127

Open
wants to merge 8 commits into
base: gz-utils2
Choose a base branch
from

Conversation

mjcarroll
Copy link
Contributor

@mjcarroll mjcarroll commented Apr 1, 2024

🎉 New feature

Summary

Adds Subprocess::Signal and Subprocess::SendExitSignal.

We discovered that using kill -9 in transport tests was too aggressive and not letting the subprocess shut down cleanly. This allows you to send SIGINT on Linux or CTRL_C_EVENT/CTRL_BREAK_EVENT on Windows to cause the subprocess to shut down cleanly.

The changes to subprocess.h will be submitted upstream so that next time we pull we will get them from there.

Test it

Added a unit test.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@mjcarroll mjcarroll requested a review from azeey as a code owner April 1, 2024 17:12
@mjcarroll mjcarroll self-assigned this Apr 1, 2024
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 81.51%. Comparing base (f928192) to head (376a278).
Report is 1 commits behind head on gz-utils2.

Files Patch % Lines
include/gz/utils/Subprocess.hh 87.50% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           gz-utils2     #127      +/-   ##
=============================================
+ Coverage      80.98%   81.51%   +0.52%     
=============================================
  Files              8        8              
  Lines            384      395      +11     
=============================================
+ Hits             311      322      +11     
  Misses            73       73              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

int signum)
{
#if defined(_WIN32)
return GenerateConsoleCtrlEvent(signum, process->hProcess);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this is not compiling on windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I haven't had a chance to boot my laptop today. will take a look in a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be resolved now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, hold, this doesn't fix the test I was trying to fix.

Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll mjcarroll requested a review from azeey April 3, 2024 01:41
@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
@azeey
Copy link
Contributor

azeey commented Jul 31, 2024

@mjcarroll do we want to try to get this into Ionic?

@azeey azeey removed the beta Targeting beta release of upcoming collection label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

2 participants