how to kill a process initiated by system()

Discussion in 'Perl Misc' started by Howard, Oct 27, 2004.

  1. Howard

    Howard Guest

    Hi All,

    I ran into a scenario that I initiate from system(), however, the
    process doesn't exit and hang over there. I am just wondering if there
    is a way to kill the process after half hour run no matter it is
    healthy or not.

    Regards,
    Howard, Oct 27, 2004
    #1
    1. Advertising

  2. Howard

    Thomas Kratz Guest

    Howard wrote:

    > Hi All,
    >
    > I ran into a scenario that I initiate from system(), however, the
    > process doesn't exit and hang over there. I am just wondering if there
    > is a way to kill the process after half hour run no matter it is
    > healthy or not.
    >
    > Regards,


    perldoc -f alarm

    Thomas

    --
    $/=$,,$_=<DATA>,s,(.*),$1,see;__END__
    s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
    $_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
    '%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
    print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
    Thomas Kratz, Oct 27, 2004
    #2
    1. Advertising

  3. Howard

    Anno Siegel Guest

    Howard <> wrote in comp.lang.perl.misc:
    > Hi All,
    >
    > I ran into a scenario that I initiate from system(), however, the
    > process doesn't exit and hang over there. I am just wondering if there
    > is a way to kill the process after half hour run no matter it is
    > healthy or not.


    That will be hard to do, because system() only returns after the external
    process has ended. You could set an alarm timer and kill the process
    from the signal handler if you knew the pid, but you don't.

    You'll be much better off creating the child process yourself, probably
    using explicit fork. The parent process knows the pid and can kill
    the child process when it runs too long.

    Anno
    Anno Siegel, Oct 27, 2004
    #3
  4. Howard

    Anno Siegel Guest

    Thomas Kratz <> wrote in comp.lang.perl.misc:
    > Howard wrote:
    >
    > > Hi All,
    > >
    > > I ran into a scenario that I initiate from system(), however, the
    > > process doesn't exit and hang over there. I am just wondering if there
    > > is a way to kill the process after half hour run no matter it is
    > > healthy or not.
    > >
    > > Regards,

    >
    > perldoc -f alarm


    Fine if you know what pid to kill, but with system() you don't.

    Anno
    Anno Siegel, Oct 27, 2004
    #4
  5. Howard

    Thomas Kratz Guest

    Anno Siegel wrote:

    > Thomas Kratz <> wrote in comp.lang.perl.misc:
    >
    >>Howard wrote:
    >>
    >>
    >>>Hi All,
    >>>
    >>>I ran into a scenario that I initiate from system(), however, the
    >>>process doesn't exit and hang over there. I am just wondering if there
    >>>is a way to kill the process after half hour run no matter it is
    >>>healthy or not.
    >>>
    >>>Regards,

    >>
    >>perldoc -f alarm

    >
    >
    > Fine if you know what pid to kill, but with system() you don't.
    >
    > Anno


    You're right. Foggy memory, I really should test before posting.
    It's time to go home now :)

    Thomas

    --
    $/=$,,$_=<DATA>,s,(.*),$1,see;__END__
    s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
    $_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
    '%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
    print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
    Thomas Kratz, Oct 27, 2004
    #5
    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. Dan
    Replies:
    5
    Views:
    2,861
    bruce barker
    Dec 1, 2003
  2. Srinivasa Raghavan Sethuraman
    Replies:
    0
    Views:
    558
    Srinivasa Raghavan Sethuraman
    Jun 30, 2004
  3. Guest
    Replies:
    2
    Views:
    2,012
    Steven Cheng[MSFT]
    Aug 18, 2005
  4. Mav
    Replies:
    5
    Views:
    115
    Mothra
    Jun 15, 2004
  5. priya
    Replies:
    2
    Views:
    115
Loading...

Share This Page