Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Fork and exec

by pc88mxer (Vicar)
on Apr 30, 2008 at 14:54 UTC ( #683693=note: print w/replies, xml ) Need Help??

in reply to Fork and exec

but when i use fork, it still wait the status of the program.
I gather that your parent is hanging someplace where you don't want it to hang. Are you calling wait or waitpid in the parent?

If you don't need the exit status of a child process, you never need to call wait or waitpid or handle SIGCHLD. A 'zombie' process will be created when the child exits, but this is simply the child's entry in the system's process table and doesn't consume any appreciable memory. Zombie entries will be released when the parent exits.

If you want to check if a child has exited without hanging, then call waitpid with the WNOHANG parameter - see perldoc -f waitpid for an example.

Replies are listed 'Best First'.
Re^2: Fork and exec
by perlmonkdr (Beadle) on May 01, 2008 at 08:28 UTC

    Ok, but i'm not using wait, waitpid or signal in this example and the parent process wait to all childs finish, please not that i use this in windows, perhaps this the problem, isn't it?


      Windows has no fork but it can be emulated. See perlfork. Over on the perldoc for perlport I see that system(1, @args) will spawn an external process without waiting for the child to terminate.

      Disclaimer: I don't do windows.

        Well guys i post the solution for this isuee

        When i think in execute multiple files without wait i say, ok, i need use childs

        Anyway the solution come more simple, like this:

        #!/usr/bin/perl use strict; use warnings; for my $a ( 1..10 ) { print "Exec: $a\n"; # Here I want execute and continue without # wait the status system "perl -e exec('')" ; } print "finish"; exit;

        It's delegate the process to other instance of perl and exist when finish, i check in the system's process table and works ok!!

        system(1, @args) can be but i'm not test

        Thk to all for your help

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://683693]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-08-17 23:11 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (184 votes). Check out past polls.