diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-11-27 09:08:56 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-11-27 09:08:56 +0100 |
| commit | 01b82d46ee52d4aeb1e1466e8d72f099354d465e (patch) | |
| tree | 968528bdb99c9619f4116f909cb6ca647580325a /executor | |
| parent | 4bd70f886bd18faa69e9b1e4a9ee1897202cf202 (diff) | |
executor: use /proc/thread-self/fail-nth instead of /proc/self/task/%d/fail-nth
Makes code slightly simpler.
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_linux.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index f1d4239a4..f887551cc 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -921,15 +921,14 @@ retry: static int inject_fault(int nth) { int fd; - char buf[128]; + char buf[16]; - sprintf(buf, "/proc/self/task/%d/fail-nth", (int)syscall(SYS_gettid)); - fd = open(buf, O_RDWR); + fd = open("/proc/thread-self/fail-nth", O_RDWR); if (fd == -1) - fail("failed to open /proc/self/task/tid/fail-nth"); + fail("failed to open /proc/thread-self/fail-nth"); sprintf(buf, "%d", nth + 1); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) - fail("failed to write /proc/self/task/tid/fail-nth"); + fail("failed to write /proc/thread-self/fail-nth"); return fd; } #endif @@ -940,11 +939,11 @@ static int fault_injected(int fail_fd) char buf[16]; int n = read(fail_fd, buf, sizeof(buf) - 1); if (n <= 0) - fail("failed to read /proc/self/task/tid/fail-nth"); + fail("failed to read /proc/thread-self/fail-nth"); int res = n == 2 && buf[0] == '0' && buf[1] == '\n'; buf[0] = '0'; if (write(fail_fd, buf, 1) != 1) - fail("failed to write /proc/self/task/tid/fail-nth"); + fail("failed to write /proc/thread-self/fail-nth"); close(fail_fd); return res; } |
