whois VS jwhois and timeout

I have a script that does a whois lookup that worked fine on a previous server. It used whois with the t option to timeout in 5 seconds. A while back I upgraded to a new server and the script had problems. I found out the new server didn't even have whois. The whois command was symlinked to jwhois so I had to modify the script to adjust for the differences. I found out that jwhois has no timeout option. That wasn't a problem for a while, but then one day I noticed my script was just waiting, and waiting, and waiting. It was stuck on a jwhois query that wasn't responding.

I got another server last month and it has whois, but must be a newer version because it no longer has the t option.

How do I set a timeout for jwhois?

Is there no longer a timeout option for doing a whois in a script?

No timeout on jwhois.

There doesn't appear to be a timeout with whois anymore either. I might just install an older version of it, but I don't know if an older version would cause any problems or not.

Just in case someone ever finds this thread searching for the same thing, I did find a solution a while back.

  $timeout = 20; #seconds
  eval {
    local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
    alarm $timeout;
    system ("jwhois $domain >> $filename");
    alarm 0;
  };
  alarm 0;

  if ($@ =~ /alarm/) { #system call timed out
#    do whatever in the event of a timeout
  }