if (rc < 0 && ckWARN(WARN_EXEC))
Perl_warner(aTHX_ WARN_EXEC,"Can't %s \"%s\": %s",
fl ? "exec" : "spawn",prog,Strerror (errno));
- if (rc > 0)
- return rc <<= 8;
- if (rc < 0)
- return 255 << 8;
- return 0;
+ if (rc >= 0)
+ return rc << 8;
+ return -1;
}
int
do_aspawn (pTHX_ SV *really,SV **mark,SV **sp)
{
- dTHR;
int rc;
char **a,*tmps,**argv;
STRLEN n_a;
int fd;
char *matches;
size_t size;
+ fpos_t pos;
};
#define MAXOPENGLOBS 10
if ((gi=searchfd (-1)) == NULL)
break;
+ gi->pos=0;
pattern=alloca (strlen (name+=13)+1);
strcpy (pattern,name);
if (!_USE_LFN)
if ((gi=searchfd (fd))==NULL)
break;
- ic=tell (fd);
- if (siz+ic>=gi->size)
- siz=gi->size-ic;
- memcpy (buf,ic+gi->matches,siz);
- lseek (fd,siz,1);
+ if (siz+gi->pos > gi->size)
+ siz = gi->size - gi->pos;
+ memcpy (buf,gi->pos+gi->matches,siz);
+ gi->pos += siz;
*rv=siz;
return 1;
}
strcpy (perlprefix,"..");
}
+int
+djgpp_fflush (FILE *fp)
+{
+ int res;
+
+ if ((res = fflush(fp)) == 0 && fp) {
+ Stat_t s;
+ if (Fstat(fileno(fp), &s) == 0 && !S_ISSOCK(s.st_mode))
+ res = fsync(fileno(fp));
+ }
+/*
+ * If the flush succeeded but set end-of-file, we need to clear
+ * the error because our caller may check ferror(). BTW, this
+ * probably means we just flushed an empty file.
+ */
+ if (res == 0 && fp && ferror(fp) == EOF) clearerr(fp);
+
+ return res;
+}