[sh] <defunct>, pipe 질문입니다.

park3250의 이미지

안녕하세요
리눅스 데몬이 구동중에 [sh] 가 계속 발생합니다

strace 추적한 결과 입니다.

452   epoll_wait(1, {}, 20, 100)        = 0
452   times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 887080879
452   epoll_wait(1, {}, 20, 100)        = 0
452   times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 887080889
452   epoll_wait(1, {}, 20, 100)        = 0
452   times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 887080899
452   epoll_wait(1, {}, 20, 100)        = 0
452   times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 887080909
452   epoll_wait(1, {}, 20, 100)        = 0
452   times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 887080919
452   epoll_wait(1, {}, 20, 100)        = 0
452   times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 887080929
452   epoll_wait(1,  <unfinished ...>
462   <... nanosleep resumed> {1, 0})   = 0
462   read(3, "\20\0\4\203\1\0\0\0\10\0\246\200\35\203\0\0d\0\0\0002\0\0\0", 65586) = 24
462   pipe([4, 5])                      = 0
462   clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb2584bd8) = 499
462   close(5)                          = 0
462   fstat64(4, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
499   set_robust_list(0xb2584be0, 0xc <unfinished ...>
462   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb1b83000
462   read(4,  <unfinished ...>
499   <... set_robust_list resumed> )   = 0
499   close(4)                          = 0
499   dup2(5, 1)                        = 1
499   close(5)                          = 0
499   execve("/bin/sh", ["sh", "-c", "find /pdfile/?? -atime +100 -a -"], [/* 40 vars */] <unfinished ...>
461   <... nanosleep resumed> {1, 0})   = 0
459   <... nanosleep resumed> {1, 0})   = 0
461   rt_sigprocmask(SIG_BLOCK, [CHLD],  <unfinished ...>
459   rt_sigprocmask(SIG_BLOCK, [CHLD],  <unfinished ...>
461   <... rt_sigprocmask resumed> [], 8) = 0
459   <... rt_sigprocmask resumed> [], 8) = 0
461   rt_sigaction(SIGCHLD, NULL,  <unfinished ...>
459   rt_sigaction(SIGCHLD, NULL,  <unfinished ...>
 
.....
 
499   stat64(".", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
499   stat64(".", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
499   stat64("./sh", 0xbf823280)        = -1 ENOENT (No such file or directory)
499   stat64("/k3/bin/sh", 0xbf823280)  = -1 ENOENT (No such file or directory)
499   stat64("/k3/bin/util/sh", 0xbf823280) = -1 ENOENT (No such file or directory)
499   stat64("/k3/bin/www/sh", 0xbf823280) = -1 ENOENT (No such file or directory)
499   stat64("/k3/mysql/bin/sh", 0xbf823280) = -1 ENOENT (No such file or directory)
499   stat64("/k3/mysql2/bin/sh", 0xbf823280) = -1 ENOENT (No such file or directory)
499   stat64("/sbin/sh", 0xbf823280)    = -1 ENOENT (No such file or directory)
499   stat64("/bin/sh", {st_mode=S_IFREG|0755, st_size=736348, ...}) = 0
499   access("/bin/sh", X_OK)           = 0
499   access("/bin/sh", R_OK)           = 0
499   stat64("/bin/sh", {st_mode=S_IFREG|0755, st_size=736348, ...}) = 0
499   access("/bin/sh", X_OK)           = 0
499   access("/bin/sh", R_OK)           = 0
499   getpgrp()                         = 452
499   rt_sigaction(SIGCHLD, {0x807ae70, [], 0}, {SIG_DFL, [], 0}, 8) = 0
499   rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
499   rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
499   rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
499   rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
499   pipe([0, 4])                      = 0
499   rt_sigprocmask(SIG_BLOCK, [INT CHLD], [CHLD], 8) = 0
499   clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7f73708) = 500
499   rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0
499   close(4)                          = 0
499   close(4)                          = -1 EBADF (Bad file descriptor)
499   pipe([4, 5])                      = 0
499   rt_sigprocmask(SIG_BLOCK, [INT CHLD], [CHLD], 8) = 0
499   clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7f73708) = 501
499   rt_sigprocmask(SIG_SETMASK, [CHLD], NULL, 8) = 0
499   close(0)                          = 0
499   close(5)                          = 0
499   close(0)                          = -1 EBADF (Bad file descriptor)
499   close(5)                          = -1 EBADF (Bad file descriptor)

중간에 pipe() 함수 호출부분이 있는데 저게 호출될때마다
[sh] 가 발생하는거 같습니다

그런데 소스상에서는 직접적으로는 pipe() 함수를 호출하지는 않는데
혹시 어떤함수를 써서 내부적으로 pipe()함수가 호출된걸까요...?

답변 부탁드립니다...

bushi의 이미지

popen() 은 pipe(), fork(clone), dup*(), exec*() 로 구현됩니다.

park3250의 이미지

popen() 후에 pclose()를 해주지 않았었네요

덕분에 해결이 되었습니다 감사합니다~

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.