[완료] core file 생성 시 core 파일이름에 pid 삭제 방법

lee3390의 이미지

안녕하세요. 리눅스를 사용하던 도중 해결이 안되는 문제가 생겨서 질문을 올리게 되었습니다.

core file pattern을 core. 형식으로 생성되게 하려고

/etc/sysctl.conf 파일에
kernel.core_pattern = core.%e
kernel.core_uses_pid = 0

이와 같이 설정을 해놓고 적용을 하였습니다.

[root@devlinux ~]# sysctl -A | grep kernel.core
kernel.core_pattern = core.%e
kernel.core_uses_pid = 0
[root@devlinux ~]# cat /proc/sys/kernel/core_pattern 
core.%e
[root@devlinux ~]# cat /proc/sys/kernel/core_uses_pid 
0

그리고 실제로 core가 떨어지게 코딩하여 실행하면 core. 형식으로 core file이 만들어집니다.

그런데 background나 어떤 특정 상황에서 다른 shell에서 kill을 시키면 core..pid 형태로 core파일이 만들어지네요

cat threader.c

#include <pthread.h>
static void* thread_sleep(void* x) { while (1) sleep(30); }
int main(int c, char** v) {
        pthread_t thr[5];
        int i;
        for (i=0; i<5; ++i)
                pthread_create(&thr[i], NULL, thread_sleep, NULL);
        while (1)
                sleep(30);
        return 0;
}

[astrix@devlinux:~]$ gcc threader.c -l pthread
[astrix@devlinux:~]$ ./a.out &
[1] 4096
[astrix@devlinux:~]$ kill -11 4096
[astrix@devlinux:~]$ ls
a.out  core.a.out.4096  threader  threader.c
[1]+  세그멘테이션 오류       (core dumped) ./a.out

이러한 상황에서도 core file을 core. 으로만 나오게 설정하는 방법 알려주세요

부탁드립니다.

bushi의 이미지


man core(5) wrote:

If a multithreaded process (or, more precisely, a process that shares
its memory with another process by being created with the CLONE_VM flag
of clone(2)) dumps core, then the process ID is always appended to the
core filename, unless the process ID was already included elsewhere in
the filename via a %p specification in /proc/sys/kernel/core_pattern.
(This is primarily useful when employing the LinuxThreads implementa-
tion, where each thread of a process has a different PID.)

OTL

lee3390의 이미지

헉.. 그럼 방법이 없는거네요 ㅠ.ㅠ

이런... ㅠ.ㅠ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.