This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / arch / um / kernel / process.c
index 694a9c9..01ad098 100644 (file)
@@ -45,7 +45,7 @@ void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
        int flags = 0, pages;
 
        if(sig_stack != NULL){
-               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
+               pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
                set_sigstack(sig_stack, pages * page_size());
                flags = SA_ONSTACK;
        }
@@ -56,7 +56,11 @@ void init_new_thread_signals(int altstack)
 {
        int flags = altstack ? SA_ONSTACK : 0;
 
-       set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags, 
+       /* NODEFER is set here because SEGV isn't turned back on when the 
+        * handler is ready to receive signals.  This causes any segfault
+        * during a copy_user to kill the process because the fault is blocked.
+        */
+       set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags | SA_NODEFER,
                    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
        set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, 
                    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
@@ -69,7 +73,7 @@ void init_new_thread_signals(int altstack)
        set_handler(SIGWINCH, (__sighandler_t) sig_handler, flags, 
                    SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
        set_handler(SIGUSR2, (__sighandler_t) sig_handler, 
-                   flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SA_NOMASK | flags, -1);
        signal(SIGHUP, SIG_IGN);
 
        init_irq_signals(altstack);
@@ -119,14 +123,10 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
 
        /* Start the process and wait for it to kill itself */
        new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
-       if(new_pid < 0) 
-               return(new_pid);
-
-       CATCH_EINTR(err = waitpid(new_pid, &status, 0));
-       if(err < 0) 
-               panic("Waiting for outer trampoline failed - errno = %d", 
-                     errno);
-
+       if(new_pid < 0) return(-errno);
+       while(((err = waitpid(new_pid, &status, 0)) < 0) && (errno == EINTR)) ;
+       if(err < 0) panic("Waiting for outer trampoline failed - errno = %d", 
+                         errno);
        if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
                panic("outer trampoline didn't exit with SIGKILL, "
                      "status = %d", status);
@@ -134,6 +134,16 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
        return(arg.pid);
 }
 
+void suspend_new_thread(int fd)
+{
+       char c;
+
+       os_stop_process(os_getpid());
+
+       if(os_read_file(fd, &c, sizeof(c)) != sizeof(c))
+               panic("read failed in suspend_new_thread");
+}
+
 static int ptrace_child(void *arg)
 {
        int pid = os_getpid();
@@ -160,7 +170,7 @@ static int start_ptraced_child(void **stack_out)
        pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
        if(pid < 0)
                panic("check_ptrace : clone failed, errno = %d", errno);
-       CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
+       n = waitpid(pid, &status, WUNTRACED);
        if(n < 0)
                panic("check_ptrace : wait failed, errno = %d", errno);
        if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
@@ -177,7 +187,7 @@ static void stop_ptraced_child(int pid, void *stack, int exitcode)
 
        if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
                panic("check_ptrace : ptrace failed, errno = %d", errno);
-       CATCH_EINTR(n = waitpid(pid, &status, 0));
+       n = waitpid(pid, &status, 0);
        if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode))
                panic("check_ptrace : child exited with status 0x%x", status);
 
@@ -197,7 +207,7 @@ void __init check_ptrace(void)
                if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
                        panic("check_ptrace : ptrace failed, errno = %d", 
                              errno);
-               CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
+               n = waitpid(pid, &status, WUNTRACED);
                if(n < 0)
                        panic("check_ptrace : wait failed, errno = %d", errno);
                if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
@@ -221,7 +231,7 @@ void __init check_ptrace(void)
 
 int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
 {
-       sigjmp_buf buf;
+       jmp_buf buf;
        int n;
 
        *jmp_ptr = &buf;