Create button and functions for decreasing NI #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this do?
Part of #13
This creates a button that will decrease the selected process' NI value.
What I learned:
Through this, I discovered that I could not lower the priority without having root privileges.
From the man page for
setpriority
:And from the man page for
renice
:What we learn here is that no non-privileged users can lower the niceness value, which in turn would increase it's priority. This is a security measure to protect vulnerability from applications taking up too much of the computer's CPU.
How to overcome this?
First I compiled the app in Xcode with created a
.app
file. When I tried to usesudo
to run the app with root privileges:It returned an error:
Illegal instruction: 4
. This error means that the OS did not understand the compiled application.As a result, I had to take the app out of sandbox mode. Basically, sandboxing is a feature in Xcode that protects your system by limiting the app's privileges. In our case, we do not want this. These settings were found in the entitlements:
I removed both the security and the sandbox settings. The entitlements section is now empty.
After doing this, I recompiled a new
.app
file, and ran this command again:Decreasing the NI value now works because
sudo
gives us the proper permissions and removing the sandbox allows the app to be understood by the OS.