On Sat, 10 Jan 2004, Lincoln A. Baxter wrote:

> Tim and Steve,
> 
> I think  this is the same problem I was having before, which I thought
> at the time was an Oracle 9i issue.  I stopped working on it for about 9
> months, put I must get us to perl 5.8 for the unicode support, so I was
> looking at it today, and I think we just figured it out (with the help
> of truss).
> 
> Read:
> 
> perldoc perlvar #search for ALRM.
> 
> In particular notice this text:
> 
>   If your system has the sigaction() function then signal han-
>   dlers are installed using it.  This means you get reliable sig-
>   nal handling.  If your system has the SA_RESTART flag it is
>   used when signals handlers are installed.  This means that sys-
>   tem calls for which restarting is supported continue rather
>   than returning when a signal arrives.  If you want your system
>   calls to be interrupted by signal delivery then do something
>   like this:
> 
>      use POSIX ':signal_h';
> 
>      my $alarm = 0;
>      sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 }
>                          or die "Error setting SIGALRM handler: $!\n";
> 
>    See POSIX.
> 
> While this text is also in the perl 5.6.1 perlvar man page, I think that
> perl 5.6.0 does not infact use SA_RESTART (or at least for some reason
> our build of it did not).  Running truss -v all on Solaris 5.8 (sun4u
> hardware), reveals that our perl 5.6 does not pass SA_RESTART to the
> sigaction routine, and perl 5.8.x does.

Actually, I'm seeing the non-SA_RESTART behavior with perl 5.8.0!  The 
problem area is this snippet of PlClient's Comm.pm:

    while ($readSize > 0) {
        my $result = $socket->read($encodedSize, $readSize,
                                   length($encodedSize));
        if (!$result) {
            return undef if defined($result);
            die "Error while reading socket: $!";
                  ^^^^^^^^^^^^^^^^
        }
        $readSize -= $result;
    }

When the client is in $socket->read() and a child terminates, the read 
call returns an undefined value and errno is EINTR.  So, unless I'm 
misunderstanding your comments, this is the converse from your 
observations.  If SA_RESTART was being used, I would not expect to see 
that error caught.

To bolster my observations, a look at the perl-5.8.0 source shows that 
SA_RESTART is only used when perl is built with PERL_OLD_SIGNALS defined:

(from util.c):

#ifdef SA_RESTART
#if defined(PERL_OLD_SIGNALS)
    act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */
#endif
#endif
#ifdef SA_NOCLDWAIT
    if (signo == SIGCHLD && handler == (Sighandler_t)SIG_IGN)
        act.sa_flags |= SA_NOCLDWAIT;
#endif

It does not appear to be a runtime choice.  This was the only mention I 
found in the base perl sources for 'SA_RESTART' - I cannot even locate 
where or how this preproc define might get set, and I know I'm not doing 
it.


Steve


Reply via email to