]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/um/os-Linux/process.c
Merge branches 'pxa-ezx', 'pxa-magician' and 'pxa-palm' into pxa
[linux-2.6-omap-h63xx.git] / arch / um / os-Linux / process.c
index 8b57eb3647f5c8bc58a8cab50d20c382eb47b354..e0477c3ee89448f72320b01a493a97cb280ecad6 100644 (file)
@@ -7,6 +7,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <signal.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <sys/ptrace.h>
 #include <sys/wait.h>
 unsigned long os_process_pc(int pid)
 {
        char proc_stat[STAT_PATH_LEN], buf[256];
-       unsigned long pc;
+       unsigned long pc = ARBITRARY_ADDR;
        int fd, err;
 
        sprintf(proc_stat, "/proc/%d/stat", pid);
-       fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0);
+       fd = open(proc_stat, O_RDONLY, 0);
        if (fd < 0) {
                printk(UM_KERN_ERR "os_process_pc - couldn't open '%s', "
-                      "err = %d\n", proc_stat, -fd);
-               return ARBITRARY_ADDR;
+                      "errno = %d\n", proc_stat, errno);
+               goto out;
        }
        CATCH_EINTR(err = read(fd, buf, sizeof(buf)));
        if (err < 0) {
                printk(UM_KERN_ERR "os_process_pc - couldn't read '%s', "
                       "err = %d\n", proc_stat, errno);
-               os_close_file(fd);
-               return ARBITRARY_ADDR;
+               goto out_close;
        }
        os_close_file(fd);
        pc = ARBITRARY_ADDR;
        if (sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
-                 "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
-                 "%*d %*d %*d %*d %*d %lu", &pc) != 1) {
+                  "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
+                  "%*d %*d %*d %*d %*d %lu", &pc) != 1)
                printk(UM_KERN_ERR "os_process_pc - couldn't find pc in '%s'\n",
                       buf);
-       }
+ out_close:
+       close(fd);
+ out:
        return pc;
 }
 
@@ -60,25 +62,26 @@ int os_process_parent(int pid)
 {
        char stat[STAT_PATH_LEN];
        char data[256];
-       int parent, n, fd;
+       int parent = FAILURE_PID, n, fd;
 
        if (pid == -1)
-               return -1;
+               return parent;
 
        snprintf(stat, sizeof(stat), "/proc/%d/stat", pid);
-       fd = os_open_file(stat, of_read(OPENFLAGS()), 0);
+       fd = open(stat, O_RDONLY, 0);
        if (fd < 0) {
-               printk(UM_KERN_ERR "Couldn't open '%s', err = %d\n", stat, -fd);
-               return FAILURE_PID;
+               printk(UM_KERN_ERR "Couldn't open '%s', errno = %d\n", stat,
+                      errno);
+               return parent;
        }
 
        CATCH_EINTR(n = read(fd, data, sizeof(data)));
-       os_close_file(fd);
+       close(fd);
 
        if (n < 0) {
-               printk(UM_KERN_ERR "Couldn't read '%s', err = %d\n", stat,
+               printk(UM_KERN_ERR "Couldn't read '%s', errno = %d\n", stat,
                       errno);
-               return FAILURE_PID;
+               return parent;
        }
 
        parent = FAILURE_PID;
@@ -98,7 +101,7 @@ void os_kill_process(int pid, int reap_child)
 {
        kill(pid, SIGKILL);
        if (reap_child)
-               CATCH_EINTR(waitpid(pid, NULL, 0));
+               CATCH_EINTR(waitpid(pid, NULL, __WALL));
 }
 
 /* This is here uniquely to have access to the userspace errno, i.e. the one
@@ -127,7 +130,7 @@ void os_kill_ptraced_process(int pid, int reap_child)
        ptrace(PTRACE_KILL, pid);
        ptrace(PTRACE_CONT, pid);
        if (reap_child)
-               CATCH_EINTR(waitpid(pid, NULL, 0));
+               CATCH_EINTR(waitpid(pid, NULL, __WALL));
 }
 
 /* Don't use the glibc version, which caches the result in TLS. It misses some
@@ -221,7 +224,7 @@ int __init can_drop_memory(void)
                goto out_unmap;
        }
 
-       printk("OK\n");
+       printk(UM_KERN_CONT "OK\n");
        ok = 1;
 
 out_unmap:
@@ -235,18 +238,21 @@ out:
 void init_new_thread_signals(void)
 {
        set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK,
-                   SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1);
+                   SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
        signal(SIGHUP, SIG_IGN);
 
-       init_irq_signals(1);
+       set_handler(SIGIO, (__sighandler_t) sig_handler,
+                   SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGALRM,
+                   SIGVTALRM, -1);
+       signal(SIGWINCH, SIG_IGN);
 }
 
 int run_kernel_thread(int (*fn)(void *), void *arg, jmp_buf **jmp_ptr)