Silence error on lock attempt#137
Merged
joeysk2012 merged 1 commit intoamazonlinux:mainfrom Mar 16, 2026
Merged
Conversation
Silence the error when attempting to create the lockfile fails. Diagnostics are still printed every 100 failures, but this single line is filling about 90% of /var/log/messages on deployed systems.
Contributor
|
LGTM |
| # nonzero. If it succeeds, it is set to 0 | ||
| echo $$ > "${lockfile}" | ||
| # shellcheck disable=SC2320 | ||
| 2>/dev/null echo $$ > "${lockfile}" |
There was a problem hiding this comment.
I would have prefered echo $$ > "${lockfile}" 2>/dev/null or { echo $$ > "${lockfile}"; } 2>/dev/null as they are easier to read
saiharsha1994
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Silence the error when attempting to create the lockfile fails. Diagnostics are still printed every 100 failures, but this single line is filling about 90% of /var/log/messages on deployed systems.
Issue #, if available:
NA
Description of changes:
This redirects stderr to /dev/null when trying to create the lockfile via stdout redirection. Without this, the following line fills about 90% of /var/log/messages:
There is already additional code around this write attempt, including a diagnostic message printed every 100 attempts.
It also has a whitespace-only change on the following comment line so the leading whitespace matches the surrounding lines.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.