-1

I have a perl script running as daemon. It hits a database every 10 seconds and if there are any jobs in the queue, it spawns a separate shell to execute an individual job. But very often script fails to fetch jobs from database.

Ideally there should be calls to DB like

read(3, "\3def\3job\rqueueb\7JobTy"..., 55) = 55
read(3, ";\0\0\6", 4)                   = 4

Below is the strace of this daemon/process. Is it waiting for something? I appreciate any help.

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

And this is immediately repeated (at least) twice more.

ikegami
  • 367,544
  • 15
  • 269
  • 518
John
  • 1
  • 1
  • 3
    I don't think an strace is of any value without the source code. Then again, if the source is Perl I doubt an strace is going to be helpful. You need to run your Perl in the debugger and set a breakpoint where you detect that no jobs are available and wait until it triggers in a situation where you know jobs are available. Then look at the program's variables to figure out what is happening. – Jim Garrison Dec 15 '16 at 05:50
  • Or, pepper your Perl script with print statements at places you think are useful. Or, post the script here -- reduced to a minimal version that still has that problem. This (strace) has very little use for people who have no clue about your script. – zdim Dec 15 '16 at 06:00
  • _llseek seems like a suspect. Would need to see the script to understand what is going on. – codeforester Dec 15 '16 at 06:17
  • 1
    I doubt the llseek is a problem. It seeks to the current position, probably to clear buffers, but I bet it doesn't matter that it fails on pipes. – ikegami Dec 15 '16 at 19:26

1 Answers1

0

That creates a child process (clone), tries to obtain data from it (read 6). The child closed the pipe, so the read returns EOF (0). This is taken to be a sign that the child has exited, so it tries to reap the child (waitpid). This fails (-1), which means $SIG{CHLD} must have been set to IGNORE. The status might have been useful.

The presence of the 8/9 pipe indicates the child will call exec. The pipe is used to notify the parent of an error manipulating file handles or calling exec. The child would have set 9 to close-on-exec, so receiving an EOF without any data from this pipe (as is the case here) indicates the exec was successful.

ikegami
  • 367,544
  • 15
  • 269
  • 518