tset RFNOTEG when we can - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 17558fbe2d50f3ca908edae3b1836c71b5d9fe00
 (DIR) parent 14695b90acb1226ee1b137350e6dbbbc73c2f0e7
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun,  4 Jun 2006 16:06:49 +0000
       
       set RFNOTEG when we can
       
       Diffstat:
         M src/libthread/Linux-sparc64-asm.s   |       3 +++
         M src/libthread/exec.c                |       3 ++-
         M src/libthread/threadimpl.h          |       9 +++++++++
       
       3 files changed, 14 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/src/libthread/Linux-sparc64-asm.s b/src/libthread/Linux-sparc64-asm.s
       t@@ -1,3 +1,6 @@
       +! Actually sparc32 assembly. 
       +! Debian's sparc64 port is a 32-bit user space.
       +
                .section        ".text", #alloc, #execinstr
                .align                8
                .skip                16
 (DIR) diff --git a/src/libthread/exec.c b/src/libthread/exec.c
       t@@ -76,10 +76,11 @@ _threadspawn(int fd[3], char *cmd, char *argv[])
                        return -1;
                case 0:
                        /* can't RFNOTEG - will lose tty */
       -                /* rfork(RFNOTEG); */
                        dup2(fd[0], 0);
                        dup2(fd[1], 1);
                        dup2(fd[2], 2);
       +                if(!isatty(0) && !isatty(1) && !isatty(2))
       +                        rfork(RFNOTEG);
                        for(i=3; i<100; i++)
                                if(i != p[1])
                                        close(i);
 (DIR) diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h
       t@@ -46,6 +46,14 @@ extern        void                makecontext(ucontext_t*, void(*)(), int, ...);
        extern pid_t rfork_thread(int, void*, int(*)(void*), void*);
        #endif
        
       +#if defined(__sun__)
       +#        define mcontext libthread_mcontext
       +#        define mcontext_t libthread_mcontext_t
       +#        define ucontext libthread_ucontext
       +#        define ucontext_t libthread_ucontext_t
       +#        include "sparc-ucontext.h"
       +#endif
       +
        #if defined(__arm__)
        int getmcontext(mcontext_t*);
        void setmcontext(const mcontext_t*);
       t@@ -53,6 +61,7 @@ void setmcontext(const mcontext_t*);
        #define        getcontext(u)        getmcontext(&(u)->uc_mcontext)
        #endif
        
       +
        typedef struct Context Context;
        typedef struct Execjob Execjob;
        typedef struct Proc Proc;