summaryrefslogtreecommitdiffstats
path: root/common/sysutils.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2004-05-11 11:54:52 +0200
committerWerner Koch <wk@gnupg.org>2004-05-11 11:54:52 +0200
commitac791c0a9a4bcd6ec1785d1689994b578a9edf82 (patch)
treebcb849c3c523ddb29e996cafc055c75491fd9ce8 /common/sysutils.c
parentAlso print agent and dirmngr info. (diff)
downloadgnupg2-ac791c0a9a4bcd6ec1785d1689994b578a9edf82.tar.xz
gnupg2-ac791c0a9a4bcd6ec1785d1689994b578a9edf82.zip
* sysutils.c (disable_core_dumps): Only set the current limit.
(enable_core_dumps): New. * gpgsm.texi (Esoteric Options): Add --debug-allow-core-dump. * gpgsm.c: New option --debug-allow-core-dump. * gpgsm.h (opt): Add member CONFIG_FILENAME. * gpgsm.c (main): Use it here instead of the local var. * server.c (gpgsm_server): Print some additional information with the hello in verbose mode.
Diffstat (limited to 'common/sysutils.c')
-rw-r--r--common/sysutils.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/common/sysutils.c b/common/sysutils.c
index 4948af57f..97fa23d95 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -70,21 +70,44 @@ trap_unaligned(void)
int
disable_core_dumps (void)
{
- #ifdef HAVE_DOSISH_SYSTEM
+#ifdef HAVE_DOSISH_SYSTEM
return 0;
- #else
- #ifdef HAVE_SETRLIMIT
+#else
+# ifdef HAVE_SETRLIMIT
struct rlimit limit;
+ /* We only set the current limit unless we were not able to
+ retrieve the old value. */
+ if (getrlimit (RLIMIT_CORE, &limit))
+ limit.rlim_max = 0;
limit.rlim_cur = 0;
- limit.rlim_max = 0;
- if( !setrlimit( RLIMIT_CORE, &limit ) )
+ if( !setrlimit (RLIMIT_CORE, &limit) )
return 0;
if( errno != EINVAL && errno != ENOSYS )
log_fatal (_("can't disable core dumps: %s\n"), strerror(errno) );
- #endif
+#endif
+ return 1;
+#endif
+}
+
+int
+enable_core_dumps (void)
+{
+#ifdef HAVE_DOSISH_SYSTEM
+ return 0;
+#else
+# ifdef HAVE_SETRLIMIT
+ struct rlimit limit;
+
+ if (getrlimit (RLIMIT_CORE, &limit))
+ return 1;
+ limit.rlim_cur = limit.rlim_max;
+ setrlimit (RLIMIT_CORE, &limit);
+ return 1; /* We always return true because trhis function is
+ merely a debugging aid. */
+#endif
return 1;
- #endif
+#endif
}