2010-04-23 17 views
6

क्या निर्देशिका को कॉन्फ़िगर करने का कोई तरीका है जहां कोर डंप फ़ाइलों को किसी विशिष्ट प्रक्रिया के लिए रखा जाता है?प्रति प्रक्रिया कॉन्फ़िगर करने योग्य कोर डंप निर्देशिका

मेरे पास सी ++ में लिखा गया एक डिमन प्रक्रिया है जिसके लिए मैं कोर डंप निर्देशिका को कॉन्फ़िगर करना चाहता हूं। वैकल्पिक रूप से फ़ाइल नाम पैटर्न भी विन्यास योग्य होना चाहिए।

मुझे /proc/sys/kernel/core_pattern के बारे में पता है, हालांकि यह पैटर्न और निर्देशिका संरचना वैश्विक स्तर पर बदल देगा।

अपाचे का निर्देश CoreDumpDirectory है - इसलिए ऐसा लगता है।

उत्तर

14

नहीं, आप इसे प्रति प्रक्रिया सेट नहीं कर सकते हैं। कोर फ़ाइल को या तो प्रक्रिया की वर्तमान कार्यशील निर्देशिका या/proc/sys/kernel/core_pattern में सेट निर्देशिका में डाम्प किया जाता है यदि पैटर्न में निर्देशिका शामिल है।

अपाचे में कोरडम्प डायरेक्टरी एक हैक है, अपाचे रजिस्ट्रार सिग्नल हैंडलर सभी सिग्नल के लिए जो कोर डंप का कारण बनता है, और इसके सिग्नल हैंडलर में वर्तमान निर्देशिका को बदलता है।

/* 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. 
    */ 
} 
संबंधित मुद्दे