/* doio.c
*
- * Copyright (c) 1991-1997, Larry Wall
+ * Copyright (c) 1991-1999, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
#include "perl.h"
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
+#ifndef HAS_SEM
#include <sys/ipc.h>
+#endif
#ifdef HAS_MSG
#include <sys/msg.h>
#endif
-#ifdef HAS_SEM
-#include <sys/sem.h>
-#endif
#ifdef HAS_SHM
#include <sys/shm.h>
# ifndef HAS_SHMAT_PROTOTYPE
if (*name == '|') {
/*SUPPRESS 530*/
for (name++; isSPACE(*name); name++) ;
+ if (*name == '\0') { /* command is missing 19990114 */
+ dTHR;
+ if (ckWARN(WARN_PIPE))
+ warner(WARN_PIPE, "Missing command in piped open");
+ errno = EPIPE;
+ goto say_false;
+ }
if (strNE(name,"-"))
TAINT_ENV();
TAINT_PROPER("piped open");
name[--len] = '\0';
/*SUPPRESS 530*/
for (; isSPACE(*name); name++) ;
+ if (*name == '\0') { /* command is missing 19990114 */
+ dTHR;
+ if (ckWARN(WARN_PIPE))
+ warner(WARN_PIPE, "Missing command in piped open");
+ errno = EPIPE;
+ goto say_false;
+ }
if (strNE(name,"-"))
TAINT_ENV();
TAINT_PROPER("piped open");
PerlIO_clearerr(fp);
}
#if defined(HAS_FCNTL) && defined(F_SETFD)
- fd = PerlIO_fileno(fp);
- fcntl(fd,F_SETFD,fd > PL_maxsysfd);
+ {
+ int save_errno = errno;
+ fd = PerlIO_fileno(fp);
+ fcntl(fd,F_SETFD,fd > PL_maxsysfd); /* can change errno */
+ errno = save_errno;
+ }
#endif
IoIFP(io) = fp;
if (writing) {
int filedev;
int fileino;
#endif
- int fileuid;
- int filegid;
+ Uid_t fileuid;
+ Gid_t filegid;
if (!PL_argvoutgv)
PL_argvoutgv = gv_fetchpv("ARGVOUT",TRUE,SVt_PVIO);
|| (_djstat_fail_bits & _STFAIL_TRUENAME)!=0
#endif
) {
- warn("Can't do inplace edit: %s would not be uniq",
+ warn("Can't do inplace edit: %s would not be unique",
SvPVX(sv) );
do_close(gv,FALSE);
continue;
if (flag != TRUE)
croak("panic: unsetting binmode"); /* Not implemented yet */
#ifdef DOSISH
-#ifdef atarist
+#if defined(atarist) || defined(__MINT__)
if (!PerlIO_flush(fp) && (fp->_flag |= _IOBIN))
return 1;
else
if (SvIOK(sv)) {
if (SvGMAGICAL(sv))
mg_get(sv);
- PerlIO_printf(fp, "%ld", (long)SvIVX(sv));
+ if (SvIsUV(sv)) /* XXXX 64-bit? */
+ PerlIO_printf(fp, "%lu", (unsigned long)SvUVX(sv));
+ else
+ PerlIO_printf(fp, "%ld", (long)SvIVX(sv));
return !PerlIO_error(fp);
}
/* FALL THROUGH */
bool
do_exec(char *cmd)
{
+ return do_exec3(cmd,0,0);
+}
+
+bool
+do_exec3(char *cmd, int fd, int do_report)
+{
register char **a;
register char *s;
char flags[10];
}
{
dTHR;
+ int e = errno;
+
if (ckWARN(WARN_EXEC))
warner(WARN_EXEC, "Can't exec \"%s\": %s",
PL_Argv[0], Strerror(errno));
+ if (do_report) {
+ PerlLIO_write(fd, (void*)&e, sizeof(int));
+ PerlLIO_close(fd);
+ }
}
}
do_execfree();
#define APPLY_TAINT_PROPER() \
STMT_START { \
- if (PL_tainting && PL_tainted) { goto taint_proper_label; } \
+ if (PL_tainted) { TAINT_PROPER(what); } \
} STMT_END
/* This is a first heuristic; it doesn't catch tainting magic. */
struct utimbuf utbuf;
#else
struct {
- long actime;
- long modtime;
+ Time_t actime;
+ Time_t modtime;
} utbuf;
#endif
Zero(&utbuf, sizeof utbuf, char);
#ifdef BIG_TIME
- utbuf.actime = (Time_t)SvNVx(*++mark); /* time accessed */
- utbuf.modtime = (Time_t)SvNVx(*++mark); /* time modified */
+ utbuf.actime = (Time_t)SvNVx(*++mark); /* time accessed */
+ utbuf.modtime = (Time_t)SvNVx(*++mark); /* time modified */
#else
- utbuf.actime = SvIVx(*++mark); /* time accessed */
- utbuf.modtime = SvIVx(*++mark); /* time modified */
+ utbuf.actime = (Time_t)SvIVx(*++mark); /* time accessed */
+ utbuf.modtime = (Time_t)SvIVx(*++mark); /* time modified */
#endif
APPLY_TAINT_PROPER();
tot = sp - mark;
}
return tot;
- taint_proper_label:
- TAINT_PROPER(what);
- return 0; /* this should never happen */
-
#undef APPLY_TAINT_PROPER
}
#endif
#ifdef HAS_SEM
case OP_SEMCTL:
+#ifdef Semctl
if (cmd == IPC_STAT || cmd == IPC_SET)
infosize = sizeof(struct semid_ds);
else if (cmd == GETALL || cmd == SETALL)
/* "short" is technically wrong but much more portable
than guessing about u_?short(_t)? */
}
+#else
+ croak("%s not implemented", PL_op_desc[optype]);
+#endif
break;
#endif
#if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
#endif
#ifdef HAS_SEM
case OP_SEMCTL: {
+#ifdef Semctl
union semun unsemds;
unsemds.buf = (struct semid_ds *)a;
ret = Semctl(id, n, cmd, unsemds);
+#else
+ croak("%s not implemented", PL_op_desc[optype]);
+#endif
}
break;
#endif
msize = SvIVx(*++mark);
mtype = (long)SvIVx(*++mark);
flags = SvIVx(*++mark);
- if (SvTHINKFIRST(mstr)) {
- if (SvREADONLY(mstr))
- croak("Can't msgrcv to readonly var");
- if (SvROK(mstr))
- sv_unref(mstr);
- }
SvPV_force(mstr, len);
mbuf = SvGROW(mstr, sizeof(long)+msize+1);