| # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Clean up after early-failure.conf if a test isn't happening" |
| author "chromium-os-dev@chromium.org" |
| |
| start on stopped crash-boot-collect |
| |
| task |
| oom score -100 # This is extremely unlikely to run out of memory |
| |
| script |
| # If there is a crash test in progress, try to wait for it to finish. |
| timeout=120 |
| while [ ${timeout} -gt 0 ] && \ |
| [ -e /run/crash_reporter/crash-test-in-progress ]; do |
| sleep 5 |
| : $((timeout -= 5)) |
| done |
| |
| # If the test is still in progress, give up. |
| if [ -e /run/crash_reporter/crash-test-in-progress ]; then |
| logger -t "${UPSTART_JOB}" "Timed out waiting for crash test to finish" |
| exit |
| fi |
| |
| # Now we know there's no crash test in progress, which means that the |
| # EarlyCrash test, if it was running, is done. |
| # If another crash test starts later, that's okay; it won't need this |
| # coreutils crash. |
| |
| # Find crashes: |
| # * from 'coreutils' |
| # * from the last 10 minutes |
| # * invoked as 'sleep 10000' |
| # And remove them |
| find /var/spool/crash/ -maxdepth 1 -name "coreutils.*.meta" -mmin -10 \ |
| -exec grep -l upload_var_is_early_boot=true {} + | \ |
| while IFS= read -r file; do |
| proclog="${file%.meta}.proclog" |
| |
| if grep -q 'sleep 10000' "${proclog}"; then |
| base="${file%.meta}" |
| logger -t "${UPSTART_JOB}" "Cleaning up files:" "${base}"* |
| rm -vf "${base}"* || true |
| fi |
| done |
| end script |