But what if nothing returns on the command line? The parent dies, killing any child that may be running. This is bad. This is very bad.
When I set up my Net::SCP::Expect module, I set up a 1 second (default) timeout to check for any error messages. I also used a 'soft_close()' followed by a 'hard_close()' in the event that the former failed. The significance of these things will be made clear shortly.
In testing, I never tried copying any particularly large files and so I never had any problems. However, I recently received an email by someone using my module that he was having trouble copying large files. It seemed that he was only getting partial copies. So, I tried it myself - he's right. When I tried copying a rather large log file over, only a portion of it was copied before the program exited.
The next step was to just use the Expect module on its own. Same problem - the program dies before the whole file is copied over. What do I discover? That the only thing keeping the parent going at all is the timeout I used for error checking and the lag caused by using the 'soft_close()' method (which always seems to slowly fail). Once I removed those, even *less* of the test file was copied over. However, this small timeout plus the lag was always enough time to copy the small files I used in testing, so that's why I never noticed until now.
So far as I can tell, if Expect doesn't get anything back on the command line (and it shouldn't since I'm running scp in quiet mode), the parent exits and kills and child process that may be running. The only workaround is to set a high 'timeout_err' value in my module, so that it has enough time to copy before the program exits.
Ouch. Big fucking ouch. An email from Roland Giersig wasn't of much help. So, what do I do now in the event there's no way to deal with this? Do I rip out the Expect module completely and replace it with one of the Term modules? I may very well have to.
UPDATE: jdavidb was kind enough to provide a fix. Hooray! Thanks jdavidb!