开发者

"No child processes" error in perl

I have a Perl script which invokes the sqlldr and loads data to a table from a flat file.

Now, my problem is, even though the sqlldr loads the table fine it is returning exit code as -1(got by using $?), when i tried using $! it says No child processes.

I'm executing this script by using sudo command

sudo -u <uname> bash
<script_name>.pl

This Perl script is working fine if i execute it directly from my user id. I really don't understand why this error shows up only when i execute through sudo user.

Please help me to understand this error.

EDIT:It's working fine if i give $SIG{CHLD} = 'DEFAULT'; in my code. But, if i remove this 开发者_开发问答step, the problem shows up again. I got this code from WWW when i was browsing about this error. Any idea what it does?


On most Unix platforms, the CHLD (sometimes also known as CLD) signal has special behavior with respect to a value of 'IGNORE'. Setting $SIG{CHLD} to 'IGNORE' on such a platform has the effect of not creating zombie processes when the parent process fails to wait() on its child processes (i.e. child processes are automatically reaped). Calling wait() with $SIG{CHLD} set to 'IGNORE' usually returns -1 on such platforms.
Excerpted from http://perl.active-venture.com/pod/perlipc-signal.html

Basically what is happening is that somewhere the CHLD signal has been set to IGNORE probably by sqlldr. When you attempt to check on the status of the child process you receive the -1 which is sometimes referred to as ECHILD. This occurs because the information about the completion status of the child process has been discarded due to the ignoring of the CHLD signal. By setting $SIG{CHLD} = 'DEFAULT'; you are indicating that the CHLD signal should be handled by the DEFAULT handler and not ignored.

I do not know why the CHLD signal is being ignored when the script is executed from sudo user versus being executed directly from your user id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜