Backtick call dies in child process inside daemon

G

google

I have written a perl script that runs at startup under Linux RHEL 3. I
use the normal startup scripts found in /etc/init.d. Everything works
fine EXCEPT that if in the perl script I spawn a child and in that
child I call something like `/bin/ping somehostname.com` the child
dies.

However, if I run the perl script directly _without_ calling it from
the /etc/init.d script, everything works fine.

In other words, the backtick call is making the child die when the
script is called with the "daemon" command in the startup script, but
not when run directly on the command line.

What could be the reason for this behavior?

Thanks, Robert Lancaster
 
J

Joe Smith

I have written a perl script that runs at startup under Linux RHEL 3. I
use the normal startup scripts found in /etc/init.d. Everything works
fine EXCEPT that if in the perl script I spawn a child and in that
child I call something like `/bin/ping somehostname.com` the child
dies.

What could be the reason for this behavior?

There is an interesting comment in /etc/init.d/functions:

# Log that something succeeded
success() {
if [ -z "${IN_INITLOG:-}" ]; then
initlog $INITLOG_ARGS -n $0 -s "$1" -e 1
else
# silly hack to avoid EPIPE killing rc.sysinit
trap "" SIGPIPE
echo "$INITLOG_ARGS -n $0 -s \"$1\" -e 1" >&21
trap - SIGPIPE
fi
[ "$BOOTUP" != "verbose" -a -z "$LSB" ] && echo_success
return 0
}
 
G

google

I am not sure if this is the same thing, but I found out what was
happening. In my Perl script I detached the terminal using
"POSIX::setsid()" but then later I (tried to) write to STDOUT. This
seemed to cause real problems. So, after detaching from the terminal I
redirected STDOUT to a file and the problem went away. Since I often
use print statements for debugging this was a hard problem to pin down.
I am still not sure why this should cause a program abort...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top