我有一个运行为守护进程的perl脚本。它每10秒就会访问一个数据库,如果队列中有任何作业,它会生成一个单独的shell来执行单个作业。但是脚本通常无法从数据库中获取作业。
理想情况下应该调用DB,如
read(3, "\3def\3job\rqueueb\7JobTy"..., 55) = 55
read(3, ";\0\0\6", 4) = 4
以下是此守护程序/进程的strace。它在等什么?我感谢任何帮助。
pipe([6, 7]) = 0
pipe([8, 9]) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0) = 31858
close(9) = 0
close(7) = 0
read(8, "", 4) = 0
close(8) = 0
fcntl64(6, F_GETFL) = 0 (flags O_RDONLY)
fstat64(6, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff7783000
_llseek(6, 0, 0xffd4e540, SEEK_CUR) = -1 ESPIPE (Illegal seek)
fstat64(6, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
read(6, "", 4096) = 0
close(6) = 0
munmap(0xf7783000, 4096) = 0
rt_sigaction(SIGHUP, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
waitpid(31858, 0xffd4e670, 0) = -1 ECHILD (No child processes)
rt_sigaction(SIGHUP, {SIG_DFL, [], 0}, NULL, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], 0}, NULL, 8) = 0
立即重复(至少)两次。
答案 0 :(得分:0)
创建子进程(clone
),尝试从中获取数据(read 6
)。孩子关闭了管道,因此读取返回EOF(0
)。这被视为孩子已经退出的标志,因此它试图收获孩子(waitpid
)。这失败了(-1
),这意味着$SIG{CHLD}
必须设置为IGNORE
。状态可能有用。
8
/ 9
管道的存在表明孩子将致电exec
。管道用于通知父项操作文件句柄或调用exec
的错误。孩子会将9
设置为close-on-exec,因此在没有来自此管道的任何数据的情况下接收EOF(如此处所示)表示exec
成功。