Skip to content

Run prelock and postlock synchronously to avoid race condition#320

Merged
SebTM merged 1 commit intobetterlockscreen:nextfrom
ti-mo:postlock-race
Feb 23, 2022
Merged

Run prelock and postlock synchronously to avoid race condition#320
SebTM merged 1 commit intobetterlockscreen:nextfrom
ti-mo:postlock-race

Conversation

@ti-mo
Copy link
Contributor

@ti-mo ti-mo commented Jan 14, 2022

Description

As reported in issue #285, running postlock in a subshell and immediately returning from lockselect() has a high chance of hitting exit 0 before xset and dunstctl get a chance to execute.

Run both prelock and postlock synchronously within lockselect().

Fixes #285

How Has This Been Tested?

Running with set -x shows both xset and dunstctl executing reliably as expected, and xset q shows the original DPMS standby time after a succesful unlock.

Checklist:

  • I have performed a self-review of my own code/checked that ShellCheck succeeds
    There are 2 existing errors unrelated to my changes:
In betterlockscreen line 610:
        local position="${geometry#*${cols[1]}}"
                                    ^--------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.

In betterlockscreen line 611:
        local resolution="${geometry%${position}*}"
                                     ^---------^ SC2295 (info): Expansions inside ${..} need to be quoted separately, otherwise they match as patterns.
  • I have made corresponding changes to the documentation (if applicable)

As reported in issue betterlockscreen#285, running postlock in a subshell and immediately
returning from lockselect() has a high chance of hitting `exit 0` before
xset and dunstctl get a chance to execute.

Run both prelock and postlock synchronously within lockselect().
@SebTM
Copy link
Collaborator

SebTM commented Feb 23, 2022

Tested it and even I can't reproduce the issue on my machines I understand it can/will possibly happen for some user and can be fixed like this without breaking something else for me (and so other users so far) - so let's take it into the next beta :)

@SebTM SebTM merged commit 0d4b898 into betterlockscreen:next Feb 23, 2022
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.

lock_timeout option overwrite DPMS Standby time

2 participants