#include <sched.h>
#include <errno.h>
#include <stdarg.h>
-#include <fcntl.h>
#include <stdlib.h>
#include <setjmp.h>
#include <sys/time.h>
#include <sys/ptrace.h>
-#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <asm/ptrace.h>
int flags = 0, pages;
if(sig_stack != NULL){
- pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2;
+ pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER);
set_sigstack(sig_stack, pages * page_size());
flags = SA_ONSTACK;
}
{
int flags = altstack ? SA_ONSTACK : 0;
- set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
+ set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags,
SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags,
SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
set_handler(SIGWINCH, (__sighandler_t) sig_handler, flags,
SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
set_handler(SIGUSR2, (__sighandler_t) sig_handler,
- SA_NOMASK | flags, -1);
- (void) CHOOSE_MODE(signal(SIGCHLD, SIG_IGN), (void *) 0);
+ flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
signal(SIGHUP, SIG_IGN);
init_irq_signals(altstack);
/* 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(-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");
+ if(new_pid < 0)
+ return(new_pid);
- return(arg.pid);
-}
+ CATCH_EINTR(err = waitpid(new_pid, &status, 0));
+ if(err < 0)
+ panic("Waiting for outer trampoline failed - errno = %d",
+ errno);
-void suspend_new_thread(int fd)
-{
- char c;
-
- os_stop_process(os_getpid());
+ if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
+ panic("outer trampoline didn't exit with SIGKILL, "
+ "status = %d", status);
- if(read(fd, &c, sizeof(c)) != sizeof(c))
- panic("read failed in suspend_new_thread");
+ return(arg.pid);
}
static int ptrace_child(void *arg)
pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
if(pid < 0)
panic("check_ptrace : clone failed, errno = %d", errno);
- n = waitpid(pid, &status, WUNTRACED);
+ CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
if(n < 0)
panic("check_ptrace : wait failed, errno = %d", errno);
if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
panic("check_ptrace : ptrace failed, errno = %d", errno);
- n = waitpid(pid, &status, 0);
+ CATCH_EINTR(n = waitpid(pid, &status, 0));
if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode))
panic("check_ptrace : child exited with status 0x%x", status);
if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
panic("check_ptrace : ptrace failed, errno = %d",
errno);
- n = waitpid(pid, &status, WUNTRACED);
+ CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
if(n < 0)
panic("check_ptrace : wait failed, errno = %d", errno);
if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr)
{
- jmp_buf buf;
+ sigjmp_buf buf;
int n;
*jmp_ptr = &buf;
- n = setjmp(buf);
+ n = sigsetjmp(buf, 1);
if(n != 0)
return(n);
(*fn)(arg);
stop_ptraced_child(pid, stack, 1);
printf("Checking for /proc/mm...");
- if(access("/proc/mm", W_OK)){
+ if(os_access("/proc/mm", OS_ACC_W_OK) < 0){
printf("not found\n");
ret = 0;
}