Welcome to mirror list, hosted at ThFree Co, Russian Federation.

platform_unix.cpp « gui « src - github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e0e796fe36a826f2fc90c18223b31aaee6c5d76c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright (C) by Erik Verbruggen <erik@verbruggen.consulting>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 */

#include <QLoggingCategory>

#include <signal.h>
#include <sys/resource.h>
#include <sys/time.h>

#include "guiutility.h"
#include "platform.h"

namespace OCC {

Q_LOGGING_CATEGORY(lcPlatform, "gui.platform")

class UnixPlatform : public Platform
{
public:
    UnixPlatform()
    {
        signal(SIGPIPE, SIG_IGN);
        setLimitsForCoreDumps();
    }

    ~UnixPlatform() override;

private:
    void setLimitsForCoreDumps();
};

UnixPlatform::~UnixPlatform()
{
}

void UnixPlatform::setLimitsForCoreDumps()
{
    // check a environment variable for core dumps
    if (!qEnvironmentVariableIsEmpty("OWNCLOUD_CORE_DUMP")) {
        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 {
            qCInfo(lcPlatform) << "Core dumps enabled";
        }
    }
}

std::unique_ptr<Platform> Platform::create()
{
    return std::make_unique<UnixPlatform>();
}

} // namespace OCC