X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=vmesa%2Fvmesa.c;h=0e4ad86682d2179a8c2a6d5e99a5cda85040d384;hb=76ced9add7b621dfc9d4ecb534aeea8e131a418a;hp=6169e70d78addb636cdfcac048adda19e14cbf38;hpb=7a66b2869e0f357e64667c2db4e33691b36245f8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/vmesa/vmesa.c b/vmesa/vmesa.c index 6169e70..0e4ad86 100644 --- a/vmesa/vmesa.c +++ b/vmesa/vmesa.c @@ -116,6 +116,7 @@ do_aspawn(SV* really, SV **mark, SV **sp) fdMap[3]; SV *sv, **p_sv; + STRLEN n_a; status = FAIL; if (sp > mark) @@ -126,7 +127,7 @@ do_aspawn(SV* really, SV **mark, SV **sp) while (++mark <= sp) { if (*mark) - *a++ = SvPVx(*mark, PL_na); + *a++ = SvPVx(*mark, n_a); else *a++ = ""; } @@ -142,7 +143,7 @@ do_aspawn(SV* really, SV **mark, SV **sp) /*-----------------------------------------------------*/ if (*PL_Argv[0] != '/') TAINT_ENV(); - if (really && *(tmps = SvPV(really, PL_na))) + if (really && *(tmps = SvPV(really, n_a))) pid = spawnp(tmps, nFd, fdMap, &inherit, (const char **) PL_Argv, (const char **) environ); @@ -181,11 +182,13 @@ do_aspawn(SV* really, SV **mark, SV **sp) /* be used by my_pclose */ /*---------------------------------------------*/ close(fd); + MUTEX_LOCK(&PL_fdpid_mutex); p_sv = av_fetch(PL_fdpid,fd,TRUE); fd = (int) SvIVX(*p_sv); SvREFCNT_dec(*p_sv); *p_sv = &PL_sv_undef; sv = *av_fetch(PL_fdpid,fd,TRUE); + MUTEX_UNLOCK(&PL_fdpid_mutex); (void) SvUPGRADE(sv, SVt_IV); SvIVX(sv) = pid; status = 0; @@ -407,10 +410,13 @@ my_popen(char *cmd, char *mode) Perl_stdin_fd = pFd[that]; if (strNE(cmd,"-")) { + PERL_FLUSHALL_FOR_CHILD; pid = spawn_cmd(cmd, Perl_stdin_fd, Perl_stdout_fd); if (pid >= 0) { + MUTEX_LOCK(&PL_fdpid_mutex); sv = *av_fetch(PL_fdpid,pFd[this],TRUE); + MUTEX_UNLOCK(&PL_fdpid_mutex); (void) SvUPGRADE(sv, SVt_IV); SvIVX(sv) = pid; fd = PerlIO_fdopen(pFd[this], mode); @@ -421,7 +427,9 @@ my_popen(char *cmd, char *mode) } else { + MUTEX_LOCK(&PL_fdpid_mutex); sv = *av_fetch(PL_fdpid,pFd[that],TRUE); + MUTEX_UNLOCK(&PL_fdpid_mutex); (void) SvUPGRADE(sv, SVt_IV); SvIVX(sv) = pFd[this]; fd = PerlIO_fdopen(pFd[this], mode); @@ -458,7 +466,9 @@ my_pclose(FILE *fp) SV **sv; FILE *other; + MUTEX_LOCK(&PL_fdpid_mutex); sv = av_fetch(PL_fdpid,PerlIO_fileno(fp),TRUE); + MUTEX_UNLOCK(&PL_fdpid_mutex); pid = (int) SvIVX(*sv); SvREFCNT_dec(*sv); *sv = &PL_sv_undef;