There appears to be a known bug in a third party tool I'm using which will cause it to 'leak' threads.  Threads will end up in a zombie state if it has certain communication issues with another program, with those threads never being cleaned.  Because this only happens when communication issues occure I don't know how long it will take for the threads to build up, it could go months without any build up, or it could build up all the way to the limit in an hour time in the worst case scenario of communication problems.I can't do much to prevent the threads from buliding up.  As a work around I would like to configure a program to automatically reboot the applicataion once it's thread count gets close to the ulimit value.  I'm wondering what the best approach for doing this is?I could write a cron job which runs every hour and checks proc status and do a reboot.  Is there any easier approach, ideally one that ensures a reboot as soon as I hit ulimit, not worse case of 59 minutes after I hit the limit as would happen with the cron job approach?
How tu automatically restart a program when it gets close to the max thread limit?
bash;cron