Hi,
There is an error in your code: you wrote system("prog2.pl") which does not invoke prog2.pl unless you have '.' (the current directory) in your PATH (which should be avoided).
By replacing your instruction with system("./prog2.pl") I get a return code of 5 both with and without SIGCHLD ignored. Just as I expected.
I expected this result because perl system emulates C system(3), and the man page of the latter states that:
During execution of the command, SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored.
That is to say: system install its own SIGCHLD handler, which is needed exactly for capturing the exit status.
I join Abigail-II in asking which version of perl, operating system and kernel are you using.
By the way, why should ignoring SIGCHLD be recommended when using system? Never heard that...
Hoping this helps
In reply to Re: why does ignoring sigCHLD corrupt return value from system()?
by TheHobbit
in thread why does ignoring sigCHLD corrupt return value from system()?
by fiberhalo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |