diff options
author | Sam Bingner <sam@bingner.com> | 2020-04-06 09:43:46 -1000 |
---|---|---|
committer | Sam Bingner <sam@bingner.com> | 2020-04-06 11:07:53 -1000 |
commit | 61197ecc317410d991fe643683a3ac49f8b2a7da (patch) | |
tree | b1204b2a6aaab89cfb0c388ba67120b804c83e4d /MobileCydia.mm | |
parent | b1e6a53c8e3ee9e45e94196306c96d1cbb56c07c (diff) |
Actually fix strange metadata.cb0 crashestesting
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 14 |
1 files changed, 12 insertions, 2 deletions
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]); |