From 61197ecc317410d991fe643683a3ac49f8b2a7da Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Mon, 6 Apr 2020 09:43:46 -1000 Subject: Actually fix strange metadata.cb0 crashes --- MobileCydia.mm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'MobileCydia.mm') diff --git a/MobileCydia.mm b/MobileCydia.mm index 25e8907..b038aa0 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -9303,9 +9303,19 @@ int main(int argc, char *argv[]) { if ([WebPreferences respondsToSelector:@selector(setWebKitLinkTimeVersion:)]) [WebPreferences setWebKitLinkTimeVersion:PACKED_VERSION(3453,0,0)]; + // Ensure we have a stdout and stderr int fd(open("/tmp/cydia.log", O_WRONLY | O_APPEND | O_CREAT, 0644)); - dup2(fd, 2); - close(fd); + // Added this because stderr output ended up in metadata.cb0 somehow once + // Perhaps we were spawned with stderr or stdout closed? + // + // Ensure we have a stdout and stderr + if (fcntl(STDOUT_FILENO, F_GETFD) == -1) { + dup2(fd, STDOUT_FILENO); + } + dup2(fd, STDERR_FILENO); + if (fd > STDERR_FILENO) { + close(fd); + } NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); -- cgit v1.2.3