Skip to content

Silence error on lock attempt#137

Merged
joeysk2012 merged 1 commit intoamazonlinux:mainfrom
petiepooo:patch-1
Mar 16, 2026
Merged

Silence error on lock attempt#137
joeysk2012 merged 1 commit intoamazonlinux:mainfrom
petiepooo:patch-1

Conversation

@petiepooo
Copy link
Copy Markdown
Contributor

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:

Feb 26 08:48:27 pnhost setup-policy-routes[1859]: /usr/share/amazon-ec2-net-utils/lib.sh: line 646: /run/amazon-ec2-net-utils/setup-policy-routes/eth0: cannot overwrite existing file

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.

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.
@joeysk2012
Copy link
Copy Markdown
Contributor

LGTM

# nonzero. If it succeeds, it is set to 0
echo $$ > "${lockfile}"
# shellcheck disable=SC2320
2>/dev/null echo $$ > "${lockfile}"
Copy link
Copy Markdown

@saiharsha1994 saiharsha1994 Mar 16, 2026

Choose a reason for hiding this comment

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

I would have prefered echo $$ > "${lockfile}" 2>/dev/null or { echo $$ > "${lockfile}"; } 2>/dev/null as they are easier to read

@joeysk2012 joeysk2012 merged commit a3540d3 into amazonlinux:main Mar 16, 2026
4 checks passed
@petiepooo petiepooo deleted the patch-1 branch March 20, 2026 15:37
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.

3 participants