perl
view release on metacpan or search on metacpan
initially closed. But we closed p[this] before. */
if (errno != EBADF) {
closepipes:
close(p[0]);
close(p[1]);
return NULL;
}
} else
fh_fl = fcntl(*mode == 'r', F_GETFD);
if (p[that] != (*mode == 'r')) { /* if fh 0/1 was initially closed. */
dup2(p[that], *mode == 'r');
close(p[that]);
}
/* Where is `this' and newfd now? */
fcntl(p[this], F_SETFD, FD_CLOEXEC);
if (newfd != -1)
fcntl(newfd, F_SETFD, FD_CLOEXEC);
if (cnt) { /* Args: "Real cmd", before first arg, the last, execing */
pid = os2_aspawn_4(aTHX_ NULL, args, cnt, ASPAWN_NOWAIT);
} else
pid = do_spawn_nowait(aTHX_ cmd);
if (newfd == -1)
close(*mode == 'r'); /* It was closed initially */
else if (newfd != (*mode == 'r')) { /* Probably this check is not needed */
dup2(newfd, *mode == 'r'); /* Return std* back. */
close(newfd);
fcntl(*mode == 'r', F_SETFD, fh_fl);
} else
fcntl(*mode == 'r', F_SETFD, fh_fl);
if (p[that] == (*mode == 'r'))
close(p[that]);
if (pid == -1) {
close(p[this]);
return NULL;
}
if (p[that] < p[this]) { /* Make fh as small as possible */
dup2(p[this], p[that]);
close(p[this]);
p[this] = p[that];
}
sv = *av_fetch(PL_fdpid,p[this],TRUE);
(void)SvUPGRADE(sv,SVt_IV);
SvIVX(sv) = pid;
PL_forkprocess = pid;
return PerlIO_fdopen(p[this], mode);
#else /* USE_POPEN */
PerlIO *res;
SV *sv;
if (cnt)
croak("List form of piped open not implemented");
# ifdef TRYSHELL
res = popen(cmd, mode);
# else
char *shell = PerlEnv_getenv("EMXSHELL");
my_setenv("EMXSHELL", PL_sh_path);
res = popen(cmd, mode);
my_setenv("EMXSHELL", shell);
# endif
sv = *av_fetch(PL_fdpid, PerlIO_fileno(res), TRUE);
(void)SvUPGRADE(sv,SVt_IV);
SvIVX(sv) = -2; /* A cooky. */
return res;
#endif /* USE_POPEN */
}
PerlIO *
my_syspopen(pTHX_ char *cmd, char *mode)
{
return my_syspopen4(aTHX_ cmd, mode, 0, NULL);
}
/******************************************************************/
#ifndef HAS_FORK
int
fork(void)
{
Perl_croak_nocontext(PL_no_func, "Unsupported function fork");
errno = EINVAL;
return -1;
}
#endif
/*******************************************************************/
/* not implemented in EMX 0.9d */
char * ctermid(char *s) { return 0; }
#ifdef MYTTYNAME /* was not in emx0.9a */
void * ttyname(x) { return 0; }
#endif
/*****************************************************************************/
/* not implemented in C Set++ */
#ifndef __EMX__
int setuid(x) { errno = EINVAL; return -1; }
int setgid(x) { errno = EINVAL; return -1; }
#endif
/*****************************************************************************/
/* stat() hack for char/block device */
#if OS2_STAT_HACK
enum os2_stat_extra { /* EMX 0.9d fix 4 defines up to 0100000 */
os2_stat_archived = 0x1000000, /* 0100000000 */
os2_stat_hidden = 0x2000000, /* 0200000000 */
os2_stat_system = 0x4000000, /* 0400000000 */
os2_stat_force = 0x8000000, /* Do not ignore flags on chmod */
};
#define OS2_STAT_SPECIAL (os2_stat_system | os2_stat_archived | os2_stat_hidden)
static void
( run in 1.511 second using v1.01-cache-2.11-cpan-39bf76dae61 )