summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2014-05-11 20:32:25 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2014-05-11 20:32:25 -0700
commit51c8106a07e9e4055950cc7d453902414e4cc5dd (patch)
treee4626ecdd191bba988c4a12dba44fa16693f261f
parent5dfa5d42a6c3bb917f7fec1ee3e83cc1c63e1010 (diff)
Standardize the formatting and logic of ReapZombie.
-rw-r--r--MobileCydia.mm51
1 files changed, 22 insertions, 29 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 1e521f7..2466937 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -4466,27 +4466,25 @@ static _H<NSMutableSet> Diversions_;
/* XXX: this should probably not use du */
execl("/usr/libexec/cydia/du", "du", "-s", [path UTF8String], NULL);
exit(1);
- _assert(false);
- }
-
- _assert(close(fds[1]) != -1);
+ } else {
+ _assert(close(fds[1]) != -1);
- if (FILE *du = fdopen(fds[0], "r")) {
- char line[1024];
- while (fgets(line, sizeof(line), du) != NULL) {
- size_t length(strlen(line));
- while (length != 0 && line[length - 1] == '\n')
- line[--length] = '\0';
- if (char *tab = strchr(line, '\t')) {
- *tab = '\0';
- value = [NSNumber numberWithUnsignedLong:strtoul(line, NULL, 0)];
+ if (FILE *du = fdopen(fds[0], "r")) {
+ char line[1024];
+ while (fgets(line, sizeof(line), du) != NULL) {
+ size_t length(strlen(line));
+ while (length != 0 && line[length - 1] == '\n')
+ line[--length] = '\0';
+ if (char *tab = strchr(line, '\t')) {
+ *tab = '\0';
+ value = [NSNumber numberWithUnsignedLong:strtoul(line, NULL, 0)];
+ }
}
- }
-
- fclose(du);
- } else _assert(close(fds[0]) != -1);
- ReapZombie(pid);
+ fclose(du);
+ } else
+ _assert(close(fds[0]) != -1);
+ } ReapZombie(pid);
return value;
}
@@ -5317,13 +5315,12 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
if (pid == 0) {
execl("/usr/bin/sbreload", "sbreload", NULL);
perror("sbreload");
+
exit(0);
- }
+ } ReapZombie(pid);
exit(0);
- }
-
- ReapZombie(pid);
+ } ReapZombie(pid);
sleep(15);
system("/usr/bin/killall backboardd SpringBoard sbreload");
@@ -8259,10 +8256,7 @@ if (kCFCoreFoundationVersionNumber < 800) {
pclose(dpkg);
exit(0);
- _assert(false);
- }
-
- ReapZombie(pid);
+ } ReapZombie(pid);
}
- (void) onIgnored:(id)control {
@@ -10136,10 +10130,9 @@ if (kCFCoreFoundationVersionNumber < 800) {
if (pid == 0) {
execlp("launchctl", "launchctl", "stop", "com.apple.SpringBoard", NULL);
perror("launchctl stop");
- exit(0);
- }
- ReapZombie(pid);
+ exit(0);
+ } ReapZombie(pid);
}
- (void) setupViewControllers {