summaryrefslogtreecommitdiff
path: root/amigaos4/amigaos.c
diff options
context:
space:
mode:
authorAndy Broad <andy@broad.ology.org.uk>2015-09-13 14:37:43 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2015-09-16 07:44:29 -0400
commit738ab09f5846887e462080d6443fb8d1e751f247 (patch)
tree28815d963b6369d436789f18cf4551d662b3e171 /amigaos4/amigaos.c
parentdee43f802e849f37f65552e91b5dda77197dc05b (diff)
downloadperl-738ab09f5846887e462080d6443fb8d1e751f247.tar.gz
amigaos4: move the amigaos exec code under amigaos4
Largely reimplements 839a9f02, 54fa14d7, e8432c63, 40262ff4. The upside is that now doio.c and pp_sys.c have much less AmigaOS specific ifdefs. As a downside, the exec code is now forked (pun only partially accidental.) The earlier story regarding fork+exec, that the AmigaOS creating thread doesn't terminate but instead continues running is both true and false. The more detailed story is that the user-observable behaviour is as with POSIX/UNIX. The thread that created the new "task" (to use the AmigaOS terms) does hang around -- but all it does is to wait for the new task to terminate, and more importantly, it holds on to the resources like filehandles. If the task were to immediately terminate, the resources would be reclaimed by the kernel.
Diffstat (limited to 'amigaos4/amigaos.c')
-rw-r--r--amigaos4/amigaos.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/amigaos4/amigaos.c b/amigaos4/amigaos.c
index 12fb577b70..8e26064f08 100644
--- a/amigaos4/amigaos.c
+++ b/amigaos4/amigaos.c
@@ -19,6 +19,9 @@
#include <fcntl.h>
#include <ctype.h>
#include <stdarg.h>
+#include <stdbool.h>
+#undef WORD
+#define WORD int16
#include <dos/dos.h>
#include <proto/dos.h>
@@ -87,7 +90,6 @@ int VARARGS68K adebug(UBYTE *fmt, ...);
char **myenviron = NULL;
char **origenviron = NULL;
-int myexecve(const char *path, char *argv[], char *envp[]);
static void createvars(char **envp);
struct args
@@ -145,7 +147,7 @@ int32 myruncommand(
return myargs.result;
}
-static char *mystrdup(const char *s)
+char *mystrdup(const char *s)
{
char *result = NULL;
size_t size;
@@ -338,7 +340,7 @@ struct command_data
struct Task *parent;
};
-int myexecvp(const char *filename, char *argv[])
+int myexecvp(bool isperlthread, const char *filename, char *argv[])
{
// adebug("%s %ld
//%s\n",__FUNCTION__,__LINE__,filename?filename:"NULL");
@@ -391,16 +393,16 @@ int myexecvp(const char *filename, char *argv[])
} while (*p++ != '\0');
}
- res = myexecve(filename, argv, myenviron);
+ res = myexecve(isperlthread, filename, argv, myenviron);
return res;
}
-int myexecv(const char *path, char *argv[])
+int myexecv(bool isperlthread, const char *path, char *argv[])
{
- return myexecve(path, argv, myenviron);
+ return myexecve(isperlthread, path, argv, myenviron);
}
-int myexecl(const char *path, ...)
+int myexecl(bool isperlthread, const char *path, ...)
{
va_list va;
char *argv[1024]; /* 1024 enough? let's hope so! */
@@ -416,9 +418,11 @@ int myexecl(const char *path, ...)
} while (argv[i++] != NULL);
va_end(va);
- return myexecve(path, argv, myenviron);
+ return myexecve(isperlthread, path, argv, myenviron);
}
+#if 0
+
int myexecve(const char *filename, char *argv[], char *envp[])
{
FILE *fh;
@@ -436,6 +440,15 @@ int myexecve(const char *filename, char *argv[], char *envp[])
// struct Task *thisTask = IExec->FindTask(0);
int result = -1;
+ StdioStore store;
+
+ dTHX;
+ if(aTHX) // I hope this is NULL when not on a interpreteer thread nor to level.
+ {
+ /* Save away our stdio */
+ amigaos_stdio_save(aTHX_ & store);
+ }
+
// adebug("%s %ld %s\n",__FUNCTION__,__LINE__,filename?filename:"NULL");
/* Calculate the size of filename and all args, including spaces and
@@ -486,7 +499,7 @@ int myexecve(const char *filename, char *argv[], char *envp[])
if (errno == ENOENT)
{
/* file didn't exist! */
- return -1;
+ goto out;
}
}
@@ -644,8 +657,10 @@ int myexecve(const char *filename, char *argv[], char *envp[])
IExec->FreeVec(full);
if (errno == ENOEXEC)
- return -1;
- return result;
+ {
+ result = -1;
+ }
+ goto out;
}
if (interpreter)
@@ -655,9 +670,18 @@ int myexecve(const char *filename, char *argv[], char *envp[])
errno = ENOMEM;
- return -1;
+out:
+
+ amigaos_stdio_restore(aTHX_ &store);
+ STATUS_NATIVE_CHILD_SET(result);
+ PL_exit_flags |= PERL_EXIT_EXPECTED;
+ if (result != -1) my_exit(result);
+
+ return(result);
}
+#endif
+
int pause(void)
{
fprintf(stderr, "Pause not implemented\n");
@@ -804,7 +828,7 @@ int popen_child()
* argv[]
*/
- myexecvp(argv[0], argv);
+ myexecvp(FALSE, argv[0], argv);
if (command)
IExec->FreeVec(command);