develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [PATCH ext/POSIX/POSIX.pm] Re: sigaction.t under QNX

From:
Norton Allen
Date:
July 6, 2001 08:54
Subject:
Re: [PATCH ext/POSIX/POSIX.pm] Re: sigaction.t under QNX
Message ID:
200107061601.MAA00597@bottesini.harvard.edu
Gurusamy Sarathy wrote:
> This is not thread-safe.  I suggest allocating the space for it on
> the savestack, either via SSNEW() or using a newSVpv()+SAVEFREESV()
> combo.

  OK, here's a version using newSVpv()+SAVEFREESV(). It seems to
  work, but it could definitely benefit from the scrutiny of
  those more familiar with manipulation of the guts.
  
    -Norton

*** ../ORIG/perl-11148/ext/POSIX/POSIX.xs	Mon Jul  2 09:00:31 2001
--- perl-11148/ext/POSIX/POSIX.xs	Fri Jul  6 11:38:36 2001
***************
*** 522,534 ****
  }
  
  static void
! restore_sigmask(sigset_t *ossetp)
  {
  	    /* Fortunately, restoring the signal mask can't fail, because
  	     * there's nothing we can do about it if it does -- we're not
  	     * supposed to return -1 from sigaction unless the disposition
  	     * was unaffected.
  	     */
  	    (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
  }
  
--- 522,535 ----
  }
  
  static void
! restore_sigmask(SV *osset_sv)
  {
  	    /* Fortunately, restoring the signal mask can't fail, because
  	     * there's nothing we can do about it if it does -- we're not
  	     * supposed to return -1 from sigaction unless the disposition
  	     * was unaffected.
  	     */
+ 	    sigset_t *ossetp = (sigset_t *) SvPV_nolen( osset_sv );
  	    (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
  }
  
***************
*** 1185,1190 ****
--- 1186,1192 ----
  	    struct sigaction act;
  	    struct sigaction oact;
  	    sigset_t sset;
+ 	    SV *osset_sv;
  	    sigset_t osset;
  	    POSIX__SigSet sigset;
  	    SV** svp;
***************
*** 1215,1221 ****
                 XSRETURN_UNDEF;
  	    ENTER;
  	    /* Restore signal mask no matter how we exit this block. */
! 	    SAVEDESTRUCTOR(restore_sigmask, &osset);
  
  	    RETVAL=-1; /* In case both oldaction and action are 0. */
  
--- 1217,1225 ----
                 XSRETURN_UNDEF;
  	    ENTER;
  	    /* Restore signal mask no matter how we exit this block. */
! 	    osset_sv = newSVpv((char *)(&osset), sizeof(sigset_t));
! 	    SAVEFREESV( osset_sv );
! 	    SAVEDESTRUCTOR(restore_sigmask, osset_sv);
  
  	    RETVAL=-1; /* In case both oldaction and action are 0. */
  



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About