7979#include < map> // for map, _Rb_tree_iterator, opera...
8080#include < mutex> // for mutex, unique_lock
8181#include < string_view> // for operator<<, operator==, string...
82+ #include < sys/stat.h> // for stat
8283#include < sys/types.h> // for ssize_t
8384#include < tuple> // for tuple, get, make_tuple
8485#include < unistd.h> // for STDERR_FILENO
@@ -1400,6 +1401,31 @@ print_backtrace()
14001401#endif
14011402}
14021403
1404+ // / check mtime of uv executable - if more than 3 months old, complain
1405+ static void
1406+ check_obsolete_uv ()
1407+ {
1408+ enum {
1409+ SECS_PER_MONTH = 30 * 24 * 3600 ,
1410+ ACCEPTED_MONTHS = 3 ,
1411+ };
1412+ struct stat s;
1413+ if (uv_argv == nullptr || stat (uv_argv[0 ], &s) != 0 ) {
1414+ return ; // either uv_argv unset or weirdly stat failed
1415+ }
1416+ time_t now = time (nullptr );
1417+ if (now - s.st_mtime < (long ) ACCEPTED_MONTHS * SECS_PER_MONTH) {
1418+ return ; // fresh enough
1419+ }
1420+ char buf[1024 ];
1421+ snprintf_ch (buf,
1422+ " \n\n " TBOLD (TRED (
1423+ " %s is more than %d months old! Please "
1424+ " upgrade and report the problem if it perisists...\n\n " )),
1425+ PACKAGE_NAME, ACCEPTED_MONTHS);
1426+ write_all (STDERR_FILENO, strlen (buf), buf);
1427+ }
1428+
14031429void crash_signal_handler (int sig)
14041430{
14051431 print_backtrace ();
@@ -1408,15 +1434,14 @@ void crash_signal_handler(int sig)
14081434 char *ptr = buf;
14091435 char *ptr_end = buf + sizeof buf;
14101436 strappend (&ptr, ptr_end, " \n " PACKAGE_NAME " has crashed" );
1411-
14121437 append_sig_desc (&ptr, ptr_end, sig);
1413-
14141438 strappend (&ptr, ptr_end, " .\n\n Please send a bug report to address " PACKAGE_BUGREPORT " .\n " );
14151439 strappend (&ptr, ptr_end, " You may find some tips how to report bugs in file doc/REPORTING_BUGS.md distributed with " PACKAGE_NAME " \n " );
14161440 strappend (&ptr, ptr_end, " (or available online at https://github.com/CESNET/UltraGrid/blob/master/doc/REPORTING-BUGS.md).\n " );
1417-
14181441 write_all (STDERR_FILENO, ptr - buf, buf);
14191442
1443+ check_obsolete_uv ();
1444+
14201445 restore_old_tio ();
14211446
14221447 signal (sig, SIG_DFL);
0 commit comments