SPUG: references, subroutines, fork

Jim Flanagan jimfl at colltech.com
Thu Nov 29 15:12:38 CST 2001


--On Thursday, November 29, 2001 12:25 PM -0800 Benjamin Franks 
<benjamin at golly.com> wrote:

     > I pass a subroutine a reference to a array.  The subroutine forks
     > off a child and then makes use of the reference to the hash.
     > However, in the parent branch of the fork, I empty/delete the
     > underlying array elements.  Even if I put the child to sleep until
     > well after the parent has deleted the array, I can still access the
     > data the reference use to point to.  I would have imagined if you
     > destroy the underlying data the reference would reflect that change.
     > What's happening...how does perl handle this situation?

  Once you fork, you have two distinct copies of all the program data. What
  happens in one process does not effect what happens in the other. It
  would be nice if things worked this way....sometimes.

  It is possible to arrange shared memory within perl, but not particularly
  portable. You might want to take a look at the IPC::Sharable module from
  CPAN

  http://search.cpan.org/search?dist=IPC-Shareable

-- 
Jim Flanagan
jimfl at colltech.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/





More information about the spug-list mailing list