home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!gatech!darwin.sura.net!wupost!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!chx400!bernina!neptune!weingart
- From: weingart@inf.ethz.ch (Tobias Weingartner)
- Subject: fork and perl
- Message-ID: <1992Sep4.163557.19733@neptune.inf.ethz.ch>
- Followup-To: weingart@inf.ethz.ch
- Keywords: fork
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: tau.inf.ethz.ch
- Reply-To: weingart@inf.ethz.ch
- Organization: ETH - Switzerland
- Date: Fri, 4 Sep 1992 16:35:57 GMT
- Lines: 59
-
-
- Hello, I have need to fork of a process under perl,
- and then have that process modify certain variables
- under the parent one.
-
- This does not seem to work. (Thinking about it, make me wonder.)
-
- I.E The following should demonstrate what I need.
-
-
- $tmp = 1;
- print "X - $tmp\n";
-
- if(fork() == 0){
- #
- # Do some timeconsuming task here
- #
- for($i = 0; $i < 10000; $i++){}
-
- $tmp = 2;
- print "XX - $tmp\n";
- exit(0);
- }
-
- print "XXX - $tmp\n";
-
- wait;
-
- print "XXXX - $tmp\n";
-
- exit(0);
-
-
- This prints out the following:
- X - 1
- XXX - 1
- XX - 2
- XXXX - 1
-
- This shows that the child can no longer modify the parents
- variables. Is this even REMOTELY possible, or do implementation
- details prevent this?
-
- This is
-
- perl -v
-
- This is perl, version 4.0
-
- $RCSfile: perl.c,v $$Revision: 4.0.1.4 $$Date: 91/06/10 01:23:07 $
- Patch level: 10
-
- Copyright (c) 1989, 1990, 1991, Larry Wall
-
- Perl may be copied only under the terms of either the Artistic License or the
- GNU General Public License, which may be found in the Perl 4.0 source kit.
-
- --Toby.
-
-