You can wrap your system command in an eval, with a suitable alarm handler set then put an alarm for your desired timeout and optionaly trap the exit from eval to see if it timedout. Dont forget to unset the alarm when you come out of the eval.
Are you forced to only try one port at a time ? If you use fork to spawn a child thread you can keep a record of the time, its PID and the number of children currently running then spawn more.
Once the number currently running hits some maximum you find good you can sleep a second or too until one exits or start killing the oldies. If you allow N concurrent children and all children took their full 45 seconds before returning this would take 819.2/N hours (2**16 * 45/(60**2)) to complete (for your script now N=1).
Cheers,
R.
In reply to Re: Sending signal to running script
by Random_Walk
in thread Sending signal to running script
by mhearse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |