在shell脚本中,如果需要执行一条指令,但是需要严格的时间控制,但是设备上没有timeout这条指令,可以使用如下方式代替
# watchdog process
mainpid=$$
(sleep 5; kill $mainpid) &
watchdogpid=$!
# rest of script
while :
do
...stuff...
done
kill $watchdogpid
在shell脚本中,如果需要执行一条指令,但是需要严格的时间控制,但是设备上没有timeout这条指令,可以使用如下方式代替
# watchdog process
mainpid=$$
(sleep 5; kill $mainpid) &
watchdogpid=$!
# rest of script
while :
do
...stuff...
done
kill $watchdogpid