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 program if ctrl+c is received #177

Merged
merged 1 commit into from
Aug 30, 2023
Merged

Conversation

SteveL-MSFT
Copy link
Member

PR Summary

Program exits if ctrl+c (sigint) is received. At this point, it's probably safer to let child processes continue to run and finish than to kill them mid-process.

PR Context

Fix #150

@@ -32,6 +32,7 @@ pub const EXIT_DSC_ERROR: i32 = 2;
pub const EXIT_JSON_ERROR: i32 = 3;
pub const EXIT_INVALID_INPUT: i32 = 4;
pub const EXIT_VALIDATION_FAILED: i32 = 5;
pub const EXIT_CTRL_C: i32 = 6;
Copy link
Collaborator

Choose a reason for hiding this comment

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

After this PR lands, I'm going to update the CLI docs to include exit codes for DSC itself.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, would it be possible to get short docs strings for these constants? That would make documenting them in CLI docs easier. Right now I'm trying to track down how they're used throughout the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can add them in a separate PR. Can probably put them in the .dsc.resource.json files. Created #181

@anmenaga
Copy link
Collaborator

At this point, it's probably safer to let child processes continue to run and finish than to kill them mid-process.

This really depends on the business logic of the resource/scenario that is running. I can see the other option valuable as well.
In short term, this is fine (assuming GC is happy with this).
In the long run, this behavior should probably be configurable by dsc config file or something of that sort.

PS. In the long run, we'll also need a timeout/cancelation protection from hanging resource processes.

@SteveL-MSFT SteveL-MSFT merged commit e47ff7c into PowerShell:main Aug 30, 2023
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the ctrlc branch August 30, 2023 21:33
@SteveL-MSFT SteveL-MSFT restored the ctrlc branch August 31, 2023 18:09
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.

Support sending control signals to DSC
3 participants