--- In perl-beginner%40yahoogroups.com">perl-beginner
yahoogroups.com, "joshypy" <joshypy
...> wrote:
>
> Thanks Sandy, Its working for me. But I am struggling to kill the
> child process later from the main program. The following is the code I
> used:
>
> $| = 1;
>
> if ($pid = fork) {
> print "End of Parent";
> $child_pid=$pid;
> } else {
>
> system ("newprogram.exe");
> exit(0);
I would try calling exec() instead of system() here. system()
introduces one more level of parent-child, which is an unnecessary
complexity here.
> }
>
> #Here I want to close the "newprogram.exe"
> kill ($child_pid);
I am not sure why do you want to kill it. You want the parent and the
child to do something in parallel, don't you? And when the parent is
done, you probably want it to wait for the child.
perldoc -f wait
perldoc -f waitpid
/sandy
http://myperlquiz.com/
.