tools/testing/selftests/net/lib/sh/defer.sh
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/lib/sh/defer.sh
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/lib/sh/defer.sh- Extension
.sh- Size
- 2280 bytes
- Lines
- 132
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function __defer__scope_wipe
Annotated Snippet
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Whether to pause and allow debugging when an executed deferred command has a
# non-zero exit code.
: "${DEFER_PAUSE_ON_FAIL:=no}"
# map[(scope_id,track,cleanup_id) -> cleanup_command]
# track={d=default | p=priority}
declare -A __DEFER__JOBS
# map[(scope_id,track) -> # cleanup_commands]
declare -A __DEFER__NJOBS
# scope_id of the topmost scope.
__DEFER__SCOPE_ID=0
__defer__ndefer_key()
{
local track=$1; shift
echo $__DEFER__SCOPE_ID,$track
}
__defer__defer_key()
{
local track=$1; shift
local defer_ix=$1; shift
echo $__DEFER__SCOPE_ID,$track,$defer_ix
}
__defer__ndefers()
{
local track=$1; shift
echo ${__DEFER__NJOBS[$(__defer__ndefer_key $track)]}
}
__defer__run()
{
local track=$1; shift
local defer_ix=$1; shift
local defer_key=$(__defer__defer_key $track $defer_ix)
local ret
eval ${__DEFER__JOBS[$defer_key]}
ret=$?
if [[ "$DEFER_PAUSE_ON_FAIL" == yes && "$ret" -ne 0 ]]; then
echo "Deferred command (track $track index $defer_ix):"
echo " ${__DEFER__JOBS[$defer_key]}"
echo "... ended with an exit status of $ret"
echo "Hit enter to continue, 'q' to quit"
read a
[[ "$a" == q ]] && exit 1
fi
unset __DEFER__JOBS[$defer_key]
}
__defer__schedule()
{
local track=$1; shift
local ndefers=$(__defer__ndefers $track)
local ndefers_key=$(__defer__ndefer_key $track)
local defer_key=$(__defer__defer_key $track $ndefers)
local defer="${@@Q}"
__DEFER__JOBS[$defer_key]="$defer"
Annotation
- Detected declarations: `function __defer__scope_wipe`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.