open3 and signals

Discussion in 'Perl Misc' started by Mike, Sep 21, 2004.

  1. Mike

    Mike Guest

    Hi,
    I am using open3 to run an external program from my perl script.
    Whenever the script recieves a Ctrl-C, it appaers the open pipes are
    immediately shutdown. I have installed a signal handler for INT, which
    sets a variable. I then immediately leave a while loop and try to send
    (CLOSE\nEXIT\n") to the write handle for the open process. But it is
    already closed.

    Looking for any ideas to try and write the message before the process
    is shudown.

    Thanks
    Mike
     
    Mike, Sep 21, 2004
    #1
    1. Advertising

  2. Mike

    Mike Guest

    I came up with a solution using IO::pipe and fork.
    I then talk to the child with the pipe, he runs the program, and talks
    back with the pipe.
    The child is in a loop checking the pipe for more request, checking
    the open3 program for r and e output. It also checks the status of the
    parent process, which i store right after the fork before the loop. if
    kill 0 $ppid returns 0, i try and shutdown the open3 program.
    If anyone would like to see the code or know more, let me know.

    I think open3 might fork also, but i cant seem to disassociate the
    child process and only have access thru the the r,w,e handles.

    Mike
     
    Mike, Sep 24, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Newberry
    Replies:
    0
    Views:
    668
    Dave Newberry
    Oct 17, 2004
  2. Daniel Berger

    open3 and background processes

    Daniel Berger, Aug 26, 2008, in forum: Ruby
    Replies:
    3
    Views:
    234
    Gennady Bystritsky
    Aug 28, 2008
  3. Une Bévue

    Open3 and ssh

    Une Bévue, Sep 2, 2008, in forum: Ruby
    Replies:
    0
    Views:
    125
    Une Bévue
    Sep 2, 2008
  4. RU
    Replies:
    4
    Views:
    137
    Darren Dunham
    Oct 3, 2007
  5. Peter Makholm

    IPC::Open3 and the error filehandle

    Peter Makholm, Oct 26, 2007, in forum: Perl Misc
    Replies:
    5
    Views:
    213
    Peter Makholm
    Oct 29, 2007
Loading...

Share This Page