[sh] <defunct>, pipe 질문입니다.
글쓴이: park3250 / 작성시간: 목, 2016/12/15 - 10:35오전
안녕하세요
리눅스 데몬이 구동중에 [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()함수가 호출된걸까요...?
답변 부탁드립니다...
Forums:
popen() 은 pipe(), fork(clone)
popen() 은 pipe(), fork(clone), dup*(), exec*() 로 구현됩니다.
답변 감사합니다..
popen() 후에 pclose()를 해주지 않았었네요
덕분에 해결이 되었습니다 감사합니다~
댓글 달기