summaryrefslogtreecommitdiff
path: root/amigaos4/amigaio.c
diff options
context:
space:
mode:
authorAndy Broad <andy@broad.ology.org.uk>2016-03-11 20:20:31 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2016-03-11 20:22:57 -0500
commit6de23f80b0db931a33c28fa9eea3c74f533d772b (patch)
treed067c9d3bb04d09830e9243eb612d76ed107e3a9 /amigaos4/amigaio.c
parente46aa1ddb7d58d270bbc45cef016b0577cfdecaa (diff)
downloadperl-6de23f80b0db931a33c28fa9eea3c74f533d772b.tar.gz
amigaos4: better popen() + pclose() implementation
popen(): handle better the case where the popened external might exit before the child process manages to start. pclose(): protect with a semaphore.
Diffstat (limited to 'amigaos4/amigaio.c')
-rw-r--r--amigaos4/amigaio.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/amigaos4/amigaio.c b/amigaos4/amigaio.c
index a5eb112400..40e9835d0f 100644
--- a/amigaos4/amigaio.c
+++ b/amigaos4/amigaio.c
@@ -18,6 +18,7 @@
#include <exec/exectags.h>
#include <proto/exec.h>
#include <proto/dos.h>
+#include <proto/utility.h>
#include <dos/dos.h>
void amigaos_stdio_get(pTHX_ StdioStore *store)
@@ -66,10 +67,18 @@ PerlIO *Perl_my_popen(pTHX_ const char *cmd, const char *mode)
*/
// FILE *f=amigaos_popen(cmd,mode);
// fprintf(stderr,"popen returned %d\n",f);
- return PerlIO_importFILE(amigaos_popen(cmd, mode), 0);
+ return PerlIO_importFILE(amigaos_popen(cmd, mode), mode);
// return PerlIO_importFILE(f, 0);
}
+I32 Perl_my_pclose(pTHX_ PerlIO *ptr)
+{
+ FILE * const f = PerlIO_findFILE(ptr);
+ const I32 result = amigaos_pclose(f);
+ PerlIO_releaseFILE(ptr,f);
+ return result;
+}
+
#ifdef USE_ITHREADS
/* An arbitrary number to start with, should work out what the real max should
@@ -747,7 +756,7 @@ int myexecve(bool isperlthread,
(contains_whitespace(*cur) ? (2 + no_of_escapes(*cur)) : 0);
}
/* Check if it's a script file */
-
+ IExec->DebugPrintF("%s %ld %08lx %c %c\n",__FILE__,__LINE__,filename,filename[0],filename[1]);
fh = fopen(filename, "r");
if (fh)
{
@@ -839,7 +848,7 @@ int myexecve(bool isperlthread,
if (esc > 0)
{
- char *buff = IExec->AllocVec(
+ char *buff = (char *)IExec->AllocVec(
strlen(*cur) + 4 + esc,
MEMF_ANY | MEMF_CLEAR);
char *p = *cur;