perlnewbie9292
Programmer
Hello,
trying to figure out how to timeout/wait xx seconds for a command to run/return before it dying out and just printing command took to long etc. Not an external command in this case I am running a simple -w to check if two different directories are writeable. The problem is that something the device/mount goes offline and when the -w check is done it just sits there forever.
I found a few examples with SIG ALARM (which I don't quite follow) but not sure if there is a better/simpler way to do this.
example simple reduced code.
Thanks for the help in advanced.
trying to figure out how to timeout/wait xx seconds for a command to run/return before it dying out and just printing command took to long etc. Not an external command in this case I am running a simple -w to check if two different directories are writeable. The problem is that something the device/mount goes offline and when the -w check is done it just sits there forever.
I found a few examples with SIG ALARM (which I don't quite follow) but not sure if there is a better/simpler way to do this.
example simple reduced code.
Code:
if ( (!-w $dirPath) && (!-w $dirPath2) ) { #how can I have this check timeout after 5 seconds if no response comes back to -w?)
do whatever
}
Thanks for the help in advanced.