No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Updated this description: I'm looking at a program in which a connection to MySQL is established via the DBI module. Then a wget command is issued that takes a long time. During that time, the database connection times out, and must send a signal to the parent. This causes $? and $! to be set. But in addition to those, the system('wget') call returns -1. I know the wget succeeds, because the file is completely downloaded. But since system() returns -1, it looks like the wget failed!
Update2: I think Tye figured this out while we were chatting in the CB: system calls waitpid, and waitpid is interrupted by the signal. So my child wget command keeps on executing the background, while the perl script resumes execution.
I wrote a sample program that shows the same problem, but I think that it might be causing confusion. I don't want the child to receive the signal, nor am I using this alarm as a timeout to make sure the system call doesn't hang. My use of alarm w/ system here may be wrong, as mr_mischief pointed out to me. I'm leaving it here though, because I *think* it demonstrates the same problem.
And so here is a test run: I searched the archives, and I found an old node that may be related. I tested this on two different systems, with two different perl version. Some system details: I haven't been able to find any documentation about this behavior. Is this intended? If so, how can I trust system's return value? In reply to System call + signals = bad return code? by swkronenfeld
|
|