in reply to IPC, trying for have child wait for commands

Win32 Perl doesn't have real fork so file handles are shared between the pseudo processes so close in one affects all of them.

Try open2 or open3 instead.

        - tye (but my friends call me "Tye")
  • Comment on (tye)Re: IPC, trying for have child wait for commands

Replies are listed 'Best First'.
Re: (tye)Re: IPC, trying for have child wait for commands
by Eradicatore (Monk) on Jun 05, 2001 at 22:38 UTC
    Thanks for the help! One question about that though. This example, if you remove me trying to wait for the PARENT_RDR to be readable, works on my win32. If close were interferring, wouldn't this example straight from the ipc help not work?

    Thanks, Justin

      Hm, it appears that Win32 Perl's close also pretends. Oh well, your code is still using things that I've found very easy to break because they are just pretending (and are still pretty new).

      select will only work on TCP/IP sockets under Win32.

      If you are blocking until you are able to read, then just call read and let if block. Your code only has an advantage when you have more than pipe you wish to read from.

              - tye (but my friends call me "Tye")
        Just to put this in context, the only reason I'm even trying to do this is because wog pointed out on my last question that it's possible to start a child process *before* you start up MainWindow in a perl/tk app and not have the child process calls to POSIX::exit get screwy. What I really wanted was to just use fork and have the children exit when they were done getting a URL, but even if I call POSIX::exit it still trys to call TK::exit! arrrrghhh!!!

        Anyway, thanks again for trying to help. I'll just have to keep at it. Your comment about just letting it block seems to work, but there is something strange about that too. I'll investigate and post later when I know more.

        Erad

Re: (tye)Re: IPC, trying for have child wait for commands
by John M. Dlugosz (Monsignor) on Jun 05, 2001 at 23:22 UTC
    No, according to perlfork man page, "Any filehandles open at the time of the fork() will be dup()-ed. Thus, the files can be closed independently in the parent and child, but beware that the dup()-ed handles will still share the same seek pointer. Changing the seek position in the parent will change it in the child and vice-versa. One can avoid this by opening files that need distinct seek pointers separately in the child."