diff options
author | Steve Kondik <steve@cyngn.com> | 2015-10-21 16:45:02 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-21 16:45:02 -0700 |
commit | 75276c24bf4d8b197d99e04a2831d3bb7e312a55 (patch) | |
tree | 587496d2c1ea396b3531e48685ae3fcd8eb779d0 /cmds | |
parent | 51ea2ebc5d13048dbf2ea094abadb890e8c3945d (diff) | |
parent | caaba96fcb34849406e362759931ffa4340a89c5 (diff) | |
download | frameworks_base-75276c24bf4d8b197d99e04a2831d3bb7e312a55.zip frameworks_base-75276c24bf4d8b197d99e04a2831d3bb7e312a55.tar.gz frameworks_base-75276c24bf4d8b197d99e04a2831d3bb7e312a55.tar.bz2 |
Merge branch 'm' of git://codeaurora.org/platform/frameworks/base into cm-13.0
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/idmap/create.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmds/idmap/create.cpp b/cmds/idmap/create.cpp index 41395f1..929f047 100644 --- a/cmds/idmap/create.cpp +++ b/cmds/idmap/create.cpp @@ -33,6 +33,7 @@ namespace { int open_idmap(const char *path) { int fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644)); + bool needUnlink = true; if (fd == -1) { ALOGD("error: open %s: %s\n", path, strerror(errno)); goto fail; @@ -43,6 +44,8 @@ namespace { } if (TEMP_FAILURE_RETRY(flock(fd, LOCK_EX | LOCK_NB)) != 0) { ALOGD("error: flock %s: %s\n", path, strerror(errno)); + // If the file is locked by another process, then we needn't unlink the file. + needUnlink = false; goto fail; } @@ -50,7 +53,7 @@ namespace { fail: if (fd != -1) { close(fd); - unlink(path); + if (needUnlink) unlink(path); } return -1; } |