nohup in perl

Discussion in 'Perl Misc' started by justme, Jun 28, 2004.

  1. justme

    justme Guest

    hi

    is there an equivalent implementation of nohup in perl, something
    like system("nohup $command" ) ??

    thanks
     
    justme, Jun 28, 2004
    #1
    1. Advertising

  2. How about:

    sub nohup {
    local $SIG{HUP} = 'IGNORE';
    my $pid = fork;
    if ($pid) { return $pid } # parent
    else { # child
    #.... command code here
    }
    }

    of course I have no idea what you are trying to do, so I can't really
    say if this would be wise to use :)

    --
    ) ( Jaap Karssenberg || Pardus [Larus] | |0| |
    : : http://pardus-larus.student.utwente.nl/~pardus | | |0|
    ) \ / ( |0|0|0|
    ",.*'*.," Proud owner of "Perl6 Essentials" 1st edition :) wannabe
     
    Jaap Karssenberg, Jun 28, 2004
    #2
    1. Advertising

  3. Jaap Karssenberg wrote:
    > How about:
    >


    use POSIX;

    > sub nohup {
    > local $SIG{HUP} = 'IGNORE';
    > my $pid = fork;
    > if ($pid) { return $pid } # parent
    > else { # child

    setsid() or die "Cannot establish session id: $!\n";
    > #.... command code here
    > }
    > }


    You probably want to disassociate from the current session ID, per above.
     
    Steven N. Hirsch, Jun 28, 2004
    #3
    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. Replies:
    1
    Views:
    629
    Gabriel Genellina
    Feb 13, 2007
  2. John [H2O]
    Replies:
    2
    Views:
    290
    Jeff McNeil
    Oct 25, 2008
  3. Gideon

    nohup and os.system

    Gideon, Mar 12, 2009, in forum: Python
    Replies:
    0
    Views:
    318
    Gideon
    Mar 12, 2009
  4. Cameron Simpson

    Re: nohup and os.system

    Cameron Simpson, Mar 12, 2009, in forum: Python
    Replies:
    0
    Views:
    413
    Cameron Simpson
    Mar 12, 2009
  5. Adriaan Renting
    Replies:
    0
    Views:
    331
    Adriaan Renting
    Apr 1, 2011
Loading...

Share This Page