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

macOS - sleep inhibiting II #9707

Merged

Conversation

kiminuo
Copy link
Collaborator

@kiminuo kiminuo commented Dec 7, 2022

Follow-up to #9548 with better inhibitor script

@kiminuo kiminuo force-pushed the feature/2022-12-07-macOS-sleep-follow-up branch from 3a60fd0 to 1e27ae5 Compare December 7, 2022 15:20
@molnard molnard requested a review from turbolay December 7, 2022 15:54
@molnard
Copy link
Collaborator

molnard commented Dec 7, 2022

Why draft? :)

caffeinatePid=\$!;
trap \"kill -9 \$caffeinatePid\" 0 SIGINT SIGTERM;
wait {{Environment.ProcessId}};
""".ReplaceLineEndings(replacementText: " ");
Copy link
Collaborator

Choose a reason for hiding this comment

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

giphy (3)

Are you sure?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment on what is happening here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

https://learn.microsoft.com/en-us/dotnet/api/system.string.replacelineendings says

This method searches for all newline sequences within the string and canonicalizes them to match the newline sequence for the current environment. For example, when running on Windows, all occurrences of non-Windows newline sequences will be replaced with the sequence CRLF. When running on Unix, all occurrences of non-Unix newline sequences will be replaced with a single LF character.

The idea was that raw-string literals would help us avoid fuss with escapings but it did not turn out as planned.

@turbolay
Copy link
Collaborator

turbolay commented Dec 7, 2022

With the last commits, tACK

2022-12-07_10-05-27.mp4

I propose to keep in mind the issue about grep and PID recycling but to figure it out later.

@kiminuo
Copy link
Collaborator Author

kiminuo commented Dec 7, 2022

test -d /proc/$PID is an alternative for that grep according to https://stackoverflow.com/questions/3043978/how-to-check-if-a-process-id-pid-exists#comment113189911_15774758

edit: No, only on linux.

@turbolay
Copy link
Collaborator

turbolay commented Dec 7, 2022

tACK on 1cbbd57
I also tried to force quit the terminal directly and it correctly kills caffeinate as well.
Everything seems to work as expected.

@kiminuo kiminuo marked this pull request as ready for review December 7, 2022 16:48
Copy link
Collaborator

@molnard molnard left a comment

Choose a reason for hiding this comment

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

tACK

@molnard molnard merged commit 17bb542 into WalletWasabi:master Dec 8, 2022
@molnard
Copy link
Collaborator

molnard commented Dec 8, 2022

Very well done.

@kiminuo kiminuo deleted the feature/2022-12-07-macOS-sleep-follow-up branch December 8, 2022 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants