diff options
Diffstat (limited to 'g10/misc.c')
-rw-r--r-- | g10/misc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c index 470307363..ec7c40a1a 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -22,10 +22,15 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #if defined(__linux__) && defined(__alpha__) #include <asm/sysinfo.h> #include <asm/unistd.h> #endif +#ifdef HAVE_SETRLIMIT + #include <sys/time.h> + #include <sys/resource.h> +#endif #include "util.h" #include "main.h" #include "options.h" @@ -70,6 +75,23 @@ trap_unaligned(void) #endif +void +disable_core_dumps() +{ + #ifdef HAVE_SETRLIMIT + struct rlimit limit; + + limit.rlim_cur = 0; + limit.rlim_max = 0; + if( setrlimit( RLIMIT_CORE, &limit ) ) + log_fatal("can't disable core dumps: %s\n", strerror(errno) ); + #else + log_info("WARNING: Program may create a core file!\n"); + #endif +} + + + u16 checksum_u16( unsigned n ) { |