mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-01-02 14:36:49 +00:00
Introduce wait_for_file function to wait for a file for a max. amount of time and have that function poll for the file to appear. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
18 lines
289 B
Plaintext
18 lines
289 B
Plaintext
|
|
# For the license, see the LICENSE file in the root directory.
|
|
|
|
function wait_for_file()
|
|
{
|
|
local filename="$1"
|
|
local timeout="$2"
|
|
|
|
local loops=$((timeout * 10)) loop
|
|
|
|
for ((loop=0; loop<loops; loop++)); do
|
|
[ -f "${filename}" ] && return 1
|
|
sleep 0.1
|
|
done
|
|
return 0
|
|
}
|
|
|