linuxserver / emulatorjs

Self hosted web based retro emulation front end with rom and art management.
382 stars 26 forks source link

Fix for exit code 141 pipefail in rom scans #44

Closed XanderStrike closed 2 years ago

XanderStrike commented 2 years ago

Fixes #43

When a rom archive contains many files, it can take some time for sha1sum to output shas for every file.

The output of sha1sum is piped into an awk that reads a single line and then immediately exits. This causes a race condition: if sha1sum is still writing to the pipe but the reader has exited, the kernel sends it SIGPIPE causing it to exit with code 141.

Since the pipefail option is set, this fails the whole script.

With this change, only the first file in the directory is passed into sha1sum. This should maintain behavior while eliminating the bug.

So far these changes have fixed the issue I was having with many of my roms. The issue can be tricky to reproduce because high single core performance can pretty much eliminate it. I can share the roms that are causing the issue, let me know.