This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
problem with exit in child process in BEGIN
authorRobin Barker <rmbarker@cpan.org>
Wed, 9 Feb 2011 16:31:39 +0000 (16:31 +0000)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 9 Feb 2011 17:17:31 +0000 (09:17 -0800)
pod/perlport.pod

index 04f2d0d..8450fc7 100644 (file)
@@ -1632,6 +1632,13 @@ enabled, a generic number will be encoded in a method compatible with
 the C library _POSIX_EXIT macro so that it can be decoded by other
 programs, particularly ones written in C, like the GNV package.  (VMS)
 
+C<exit()> resets file pointers, which is a problem when called 
+from a child process (created by C<fork()>) in C<BEGIN>.  
+A workaround is to use C<POSIX::_exit>.  (Solaris)
+
+    exit unless $Config{archname} =~ /\bsolaris\b/;
+    require POSIX and POSIX::_exit(0);
+
 =item fcntl
 
 Not implemented. (Win32)