in reply to problem with forking

See fork for more information. If the fork() succeeds, the parent process will receive the pid of the child process. The child process, which I assume you want to launch the other program, will receive zero.

Also, I expect you want to use exec to launch the program, not backticks. Otherwise, you probably need to call exit in the child process so it won't continue to fork off programs.

sub launch_chimera { my $pid = fork(); die "Unable to fork\n" unless defined $pid; return if $pid; exec(qw( chimera --send test.pdf )); }

Replies are listed 'Best First'.
Re^2: problem with forking
by sandeep.ses (Acolyte) on Jul 05, 2004 at 22:40 UTC
    thanks a lot . i tried using exec it worked fine. Sandeep

      Another way to run applications instead of using exec or fork is to use expect; from the Expect module.
      This is very useful for unruly programs that cause your Perl to hang.
      I have also used open3 instead of fork / exec but am now currently converting open3 to expect. #Even though it only is available for linux it might be useful to you.

      Everything I know is here
      http://search.cpan.org/dist/Expect.pm/

      Some code that uses this