nefelim4ag / Ananicy

Ananicy - is Another auto nice daemon, with community rules support (Use pull request please)
GNU General Public License v3.0
567 stars 78 forks source link

Rules match based on any argument #35

Closed pyamsoft closed 6 years ago

pyamsoft commented 7 years ago

_steam.rules contains a line which matches for the Planetary Annihilation game
by searching for the name PA

On my system, a couple of scripts run with an argument like PATH=... which is how I came
to notice this strange behavior.

Commands which run with any kind of argument looking like ...PA... will match with the
_steam.rules file and be run under TYPE=GAME incorrectly. This is because pgrep -f -w PA
matches any command whose full name includes the text PA anywhere in it.

This can be most easily observed with the following:

[in one terminal]
$ vim PATH

[in another terminal]
$ pgrep -f -w PA

Ananicy will also log to the system journal that it is setting nice levels to -5 for the random vim process.

I have fixed this on my system by changing the PA line in _steam.rules to ^PA$ but I am
unsure if this has any negative side effects since I do not actually run Planitary Anihilation.

nefelim4ag commented 7 years ago

@pyamsoft, i think that i've fix that: https://github.com/Nefelim4ag/Ananicy/commit/533831293fc275c50c65cbbbb0dbfe5e01e21363

pyamsoft commented 7 years ago

It does not seem like ananicy accepts the patch as valid rule syntax. The PA command does not appear anywhere in the output of ananicy dump rules

As a follow up, related issue, I've noticed this issue happens with effectively any profile.

For example, if I open a file in $EDITOR which is named as any program, it incorrectly adopts the nice level.

$ vim cmake adopts the cmake profile of nice 19, best-effort ionice 7. $ nano i3 adopts the i3 profile of low latency.

I believe this is because pgrep -f matches the command to any point in the name. Instead of using pgrep -f, you may want to move back to just pgrep which will only match to the actual command, instead of the full input.

Please let me know if you want to continue in this issue or open a new one.

terencode commented 6 years ago

@Nefelim4ag during startup: /usr/bin/ananicy: line 83: RULES_CACHE_TMP/./PA ..rule: No such file or directory

nefelim4ag commented 6 years ago

@terencode, https://github.com/Nefelim4ag/Ananicy/commit/d5ba2ddfa0ce2a238a222ba241ebdc0378c0a832

terencode commented 6 years ago

@Nefelim4ag yup, fixed since this commit. Shouldn't this issue be closed now?

nefelim4ag commented 6 years ago

Thanks!