настраиваемый каталог дампа ядра для каждого процесса

Существует ли способ настроить каталог, куда файлы дампа ядра помещаются для определенного процесса?

Я сделал, чтобы демон обработал записанный в C++, для которого я хотел бы настроить каталог дампа ядра. Дополнительно шаблон имени файла должен настраиваться, также.

Я знаю о /proc/sys/kernel/core_pattern, однако это изменило бы шаблон и структуру каталогов глобально.

Apache имеет директиву CoreDumpDirectory - таким образом, это, кажется, возможно.

7
задан Hanno S. 23 April 2010 в 11:48
поделиться

1 ответ

Нет, вы не можете установить его для каждого процесса. Основной файл выгружается либо в текущий рабочий каталог процесса, либо в каталог, заданный в / proc / sys / kernel / core_pattern, если шаблон включает каталог.

CoreDumpDirectory в apache - это уловка, apache регистрирует обработчики сигналов для всех сигналов, вызывающих дамп ядра, и изменяет текущий каталог в своем обработчике сигналов.

/* handle all varieties of core dumping signals */
static void sig_coredump(int sig)
{
    apr_filepath_set(ap_coredump_dir, pconf);
    apr_signal(sig, SIG_DFL);
#if AP_ENABLE_EXCEPTION_HOOK
    run_fatal_exception_hook(sig);
#endif
    /* linuxthreads issue calling getpid() here:
     *   This comparison won't match if the crashing thread is
     *   some module's thread that runs in the parent process.
     *   The fallout, which is limited to linuxthreads:
     *   The special log message won't be written when such a
     *   thread in the parent causes the parent to crash.
     */
    if (getpid() == parent_pid) {
        ap_log_error(APLOG_MARK, APLOG_NOTICE,
                     0, ap_server_conf,
                     "seg fault or similar nasty error detected "
                     "in the parent process");
        /* XXX we can probably add some rudimentary cleanup code here,
         * like getting rid of the pid file.  If any additional bad stuff
         * happens, we are protected from recursive errors taking down the
         * system since this function is no longer the signal handler   GLA
         */
    }
    kill(getpid(), sig);
    /* At this point we've got sig blocked, because we're still inside
     * the signal handler.  When we leave the signal handler it will
     * be unblocked, and we'll take the signal... and coredump or whatever
     * is appropriate for this particular Unix.  In addition the parent
     * will see the real signal we received -- whereas if we called
     * abort() here, the parent would only see SIGABRT.
     */
}
15
ответ дан 6 December 2019 в 14:02
поделиться
Другие вопросы по тегам:

Похожие вопросы: