Merge "liblogcat: avoid double close." am: 76ecdd6a95 am: e79d41bf0b
am: 0174e7019b
Change-Id: I1bc899305fabef394f76926f3eee24671743dd60
This commit is contained in:
commit
efa594ebde
2 changed files with 9 additions and 5 deletions
|
|
@ -1831,11 +1831,10 @@ int android_logcat_destroy(android_logcat_context* ctx) {
|
||||||
}
|
}
|
||||||
android::close_output(context);
|
android::close_output(context);
|
||||||
android::close_error(context);
|
android::close_error(context);
|
||||||
|
|
||||||
if (context->fds[1] >= 0) {
|
if (context->fds[1] >= 0) {
|
||||||
// NB: could be closed by the above fclose(s), ignore error.
|
// NB: this should be closed by close_output, but just in case...
|
||||||
int save_errno = errno;
|
|
||||||
close(context->fds[1]);
|
close(context->fds[1]);
|
||||||
errno = save_errno;
|
|
||||||
context->fds[1] = -1;
|
context->fds[1] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
@ -98,8 +99,12 @@ FILE* android_logcat_popen(android_logcat_context* ctx, const char* command) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE* retval = fdopen(fd, "reb");
|
int duped = dup(fd);
|
||||||
if (!retval) android_logcat_destroy(ctx);
|
FILE* retval = fdopen(duped, "reb");
|
||||||
|
if (!retval) {
|
||||||
|
close(duped);
|
||||||
|
android_logcat_destroy(ctx);
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue