diff options
author | Shashank Mittal <mittals@codeaurora.org> | 2011-02-07 20:53:56 -0800 |
---|---|---|
committer | Shashank Mittal <mittals@codeaurora.org> | 2011-02-07 22:04:05 -0800 |
commit | d96ad66076c70cd472bd36fc128031750751c09b (patch) | |
tree | cd79e1bfae7bcf157df5cb584c4f83809de76cbf | |
parent | ed9f6704b4a6073b8525c8c438e4fbd9a1dd1086 (diff) | |
download | bionic-d96ad66076c70cd472bd36fc128031750751c09b.zip bionic-d96ad66076c70cd472bd36fc128031750751c09b.tar.gz bionic-d96ad66076c70cd472bd36fc128031750751c09b.tar.bz2 |
[bionic]: Fixing futex problem in cpuacct update.M8260AAABQNLZA301103
With fprintf, sometimes after fork child process gets stuck in fuxtex
waiting queue. To fix this problem this change opens the file in SYNC
mode using open command and writes to the file using write command.
CRs-Fixed: 272695
Change-Id: Ia91b789effca2dafa12ee388211f7e54001fb8cb
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
-rwxr-xr-x[-rw-r--r--] | libc/bionic/cpuacct.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libc/bionic/cpuacct.c b/libc/bionic/cpuacct.c index 7317073..1d12308 100644..100755 --- a/libc/bionic/cpuacct.c +++ b/libc/bionic/cpuacct.c @@ -29,17 +29,18 @@ #include <stdio.h> #include <errno.h> #include <sys/stat.h> +#include <fcntl.h> #include "cpuacct.h" int cpuacct_add(uid_t uid) { int count; - FILE *fp; + int fd; char buf[80]; count = snprintf(buf, sizeof(buf), "/acct/uid/%d/tasks", uid); - fp = fopen(buf, "w+"); - if (!fp) { + fd = open(buf, O_RDWR| O_SYNC); + if (fd < 0) { /* Note: sizeof("tasks") returns 6, which includes the NULL char */ buf[count - sizeof("tasks")] = 0; if (mkdir(buf, 0775) < 0) @@ -47,13 +48,13 @@ int cpuacct_add(uid_t uid) /* Note: sizeof("tasks") returns 6, which includes the NULL char */ buf[count - sizeof("tasks")] = '/'; - fp = fopen(buf, "w+"); + fd = open(buf, O_RDWR| O_SYNC); } - if (!fp) + if (fd < 0) return -errno; - fprintf(fp, "0"); - if (fclose(fp)) + write(fd, "0", 2); + if (close(fd)) return -errno; return 0; |