diff options
Diffstat (limited to 'arch/um/os-Linux')
| -rw-r--r-- | arch/um/os-Linux/file.c | 19 | ||||
| -rw-r--r-- | arch/um/os-Linux/process.c | 16 |
2 files changed, 30 insertions, 5 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index f55773c819e6..3bd10deea280 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c | |||
| @@ -272,14 +272,23 @@ int os_connect_socket(char *name) | |||
| 272 | snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name); | 272 | snprintf(sock.sun_path, sizeof(sock.sun_path), "%s", name); |
| 273 | 273 | ||
| 274 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 274 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
| 275 | if(fd < 0) | 275 | if(fd < 0) { |
| 276 | return(fd); | 276 | err = -errno; |
| 277 | goto out; | ||
| 278 | } | ||
| 277 | 279 | ||
| 278 | err = connect(fd, (struct sockaddr *) &sock, sizeof(sock)); | 280 | err = connect(fd, (struct sockaddr *) &sock, sizeof(sock)); |
| 279 | if(err) | 281 | if(err) { |
| 280 | return(-errno); | 282 | err = -errno; |
| 283 | goto out_close; | ||
| 284 | } | ||
| 281 | 285 | ||
| 282 | return(fd); | 286 | return fd; |
| 287 | |||
| 288 | out_close: | ||
| 289 | close(fd); | ||
| 290 | out: | ||
| 291 | return err; | ||
| 283 | } | 292 | } |
| 284 | 293 | ||
| 285 | void os_close_file(int fd) | 294 | void os_close_file(int fd) |
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index 7f5e2dac2a35..d261888f39c4 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "irq_user.h" | 19 | #include "irq_user.h" |
| 20 | #include "kern_util.h" | 20 | #include "kern_util.h" |
| 21 | #include "longjmp.h" | 21 | #include "longjmp.h" |
| 22 | #include "skas_ptrace.h" | ||
| 22 | 23 | ||
| 23 | #define ARBITRARY_ADDR -1 | 24 | #define ARBITRARY_ADDR -1 |
| 24 | #define FAILURE_PID -1 | 25 | #define FAILURE_PID -1 |
| @@ -100,6 +101,21 @@ void os_kill_process(int pid, int reap_child) | |||
| 100 | 101 | ||
| 101 | } | 102 | } |
| 102 | 103 | ||
| 104 | /* This is here uniquely to have access to the userspace errno, i.e. the one | ||
| 105 | * used by ptrace in case of error. | ||
| 106 | */ | ||
| 107 | |||
| 108 | long os_ptrace_ldt(long pid, long addr, long data) | ||
| 109 | { | ||
| 110 | int ret; | ||
| 111 | |||
| 112 | ret = ptrace(PTRACE_LDT, pid, addr, data); | ||
| 113 | |||
| 114 | if (ret < 0) | ||
| 115 | return -errno; | ||
| 116 | return ret; | ||
| 117 | } | ||
| 118 | |||
| 103 | /* Kill off a ptraced child by all means available. kill it normally first, | 119 | /* Kill off a ptraced child by all means available. kill it normally first, |
| 104 | * then PTRACE_KILL it, then PTRACE_CONT it in case it's in a run state from | 120 | * then PTRACE_KILL it, then PTRACE_CONT it in case it's in a run state from |
| 105 | * which it can't exit directly. | 121 | * which it can't exit directly. |
