You're correct, there is none. It shouldn't be that hard to implement it by creating a related attribute and setting it in the runCommand method call. Since I already have one implemented in Siebel::Srvrmgr::Daemon and I really need to have complete control, I'm not considering IPC::Open3::Callback right now (but it would be worth checking it again later).
During additional tests yesterday, I was able to run Siebel::Srvrmgr::Daemon several times without problem in Linux and being able to read STDERR as well. Unfortunately, I got the same error (ECONNRESET) that I was getting in Windows 7 when I repeated the test today:
Researching the error in Google, I found this http://stackoverflow.com/questions/16675950/perl-select-returning-undef-on-sysread-when-using-windows-ipcopen3-and-ios, which led me to disable using shutdown in the sockets when running in Windows. It worked, but I'm not sure why besides this explanation in the documentation:
It's also a more insistent form of close because it also disables the file descriptor in any forked copies in other processes.
Since select and Scalar::Util openhandle tells me that the handles are OK for reading/writing, I clueless why this error happens. It seems to be related to some inactivity with the child process because if I keep calling run method sequentially, everything keeps working as expected. If I "wait" a bit, the error happens.
This is the modified version of mswin_pipe that seems to be working as expected:
I believe this needs more testing. I'll repeat the tests by forking a different program and see what happens in Windows. It would make sense to set SO_KEEPALIVE to the sockets/handles?
Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
| [reply] [d/l] [select] |
| [reply] [d/l] |
Nowadays I'm running this code in Linux and Windows 7, so no emulation here. :-)
I still trying to understand this trick of using sockets instead of filehandles in Windows to be able to do select without blocking. It seems it solves the problem of blocking, but now I'm having other types of problem. Meanwhile, I will try to answer your question by quoting the same book that is helping me out (Network Programming with Perl from Lincoln D. Stein):
- about Socket's domain, page 63
AF_UNIX is used for interprocess communication within a single host. The name AF_UNIX is unfairly UNIX-specific; it's possible for non-UNIX systems to implement it. For this reason, POSIX has tried to rename this constant AF_LOCAL, although few systems have followed suit.
- About socketpair, page 101:
While in principle socketpair can be used for INET protocol, in practice most systems only support socketpair for creating UNIX-domain sockets.
Of course, I didn't know about those details before researching. As I said before, I just copied the related code and tried to adapt it to my needs.
End of story: after disabling shutdown, the application (srvrmgr.exe) that I'm executing with open3 started behaving correctly (can be reused several times), but waitpid is not being able to kill it later: it was necessary to invoke kill 9 to do the job.
Strange as it seems, running a external process as the Perl script that is shipped with Siebel::Srvrmgr works fine with waitpid in Windows and Linux.
I had updated the SVN repository if you want to take a look.
Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
| [reply] [d/l] [select] |