Enable core dumping if the env variable OWNCLOUD_CORE_DUMP is defined

Set OWNCLOUD_CORE_DUMP to anything to get a core dump in case of
crashing.
This commit is contained in:
Klaas Freitag 2014-05-15 11:01:21 +02:00
parent ef44a59bed
commit f89bfce068

View File

@ -1,4 +1,5 @@
/*
*
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
*
* This program is free software; you can redistribute it and/or modify
@ -11,8 +12,15 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <QtGlobal>
#include <signal.h>
#ifdef Q_OS_UNIX
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include "mirall/application.h"
#include "mirall/theme.h"
#include "mirall/utility.h"
@ -51,6 +59,20 @@ int main(int argc, char **argv)
return 0;
}
// check a environment variable for core dumps
#ifdef Q_OS_UNIX
if( !qgetenv("OWNCLOUD_CORE_DUMP").isEmpty() ) {
struct rlimit core_limit;
core_limit.rlim_cur = RLIM_INFINITY;
core_limit.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &core_limit) < 0) {
fprintf(stderr, "Unable to set core dump limit\n");
} else {
qDebug() << "Core dumps enabled";
}
}
#endif
// if handleStartup returns true, main()
// needs to terminate here, e.g. because
// the updater is triggered