From 17558fbe2d50f3ca908edae3b1836c71b5d9fe00 Mon Sep 17 00:00:00 2001 From: rsc Date: Sun, 4 Jun 2006 16:06:49 +0000 Subject: [PATCH] set RFNOTEG when we can --- src/libthread/Linux-sparc64-asm.s | 3 +++ src/libthread/exec.c | 3 ++- src/libthread/threadimpl.h | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libthread/Linux-sparc64-asm.s b/src/libthread/Linux-sparc64-asm.s index c371266f..422a1b24 100644 --- a/src/libthread/Linux-sparc64-asm.s +++ b/src/libthread/Linux-sparc64-asm.s @@ -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 diff --git a/src/libthread/exec.c b/src/libthread/exec.c index a6d536ec..3c71e4b1 100644 --- a/src/libthread/exec.c +++ b/src/libthread/exec.c @@ -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); diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 12b8a998..bc0667f7 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -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*); @@ -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;