This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
amigaos4: save and restore stdio handles around exec
authorAndy Broad <andy@broad.ology.org.uk>
Tue, 25 Aug 2015 23:53:13 +0000 (19:53 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 5 Sep 2015 15:12:44 +0000 (11:12 -0400)
pp_sys.c

index 12e235c..194d2eb 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4440,6 +4440,9 @@ PP(pp_exec)
 {
     dSP; dMARK; dORIGMARK; dTARGET;
     I32 value;
+#if defined(__amigaos4__)
+    amigaos_stdio_store store;
+#endif
 
     if (TAINTING_get) {
        TAINT_ENV();
@@ -4451,6 +4454,12 @@ PP(pp_exec)
        MARK = ORIGMARK;
        TAINT_PROPER("exec");
     }
+#if defined(__amigaos4__)
+    /* Make sure redirection behaves after exec.  Yes, in AmigaOS the
+     * original process continues after exec, since processes are more
+     * like threads. */
+    amigaos_stdio_save(aTHX_ &store);
+#endif
     PERL_FLUSHALL_FOR_CHILD;
     if (PL_op->op_flags & OPf_STACKED) {
        SV * const really = *++MARK;
@@ -4470,6 +4479,12 @@ PP(pp_exec)
 #endif
     }
 
+#if defined(__amigaos4__)
+    amigaos_stdio_restore(aTHX_ &store);
+    STATUS_NATIVE_CHILD_SET(value);
+    PL_exit_flags |= PERL_EXIT_EXPECTED;
+    if (value != -1) my_exit(value);
+#endif
     SP = ORIGMARK;
     XPUSHi(value);
     RETURN;