Signals, including the alarm signal, will only interrupt Perl when it is safe to do so. It would not be safe to do so in the middle of your database driver's C code, so Perl waits for the driver to return first. If the infinite loop occurs in your database driver's C code,
will not help you without switching to unsafe signals.