if we can't get the path of stdout, try stderr (that happens when 'rake spec | ...')

This commit is contained in:
Laurent Sansonetti
2012-09-07 14:50:54 +02:00
parent 721cf1d42b
commit a34c92b09c

View File

@@ -938,16 +938,21 @@ main(int argc, char **argv)
((void (*)(id, SEL, id))objc_msgSend)(config,
@selector(setLocalizedClientName:), @"NYANCAT");
char path[MAXPATHLEN];
fcntl(STDOUT_FILENO, F_GETPATH, &path);
((void (*)(id, SEL, id))objc_msgSend)(config,
@selector(setSimulatedApplicationStdOutPath:),
[NSString stringWithUTF8String:path]);
char path[MAXPATHLEN] = {'\0'};
if (fcntl(STDOUT_FILENO, F_GETPATH, &path) == -1
&& fcntl(STDERR_FILENO, F_GETPATH, &path) == -1) {
fprintf(stderr,
"*** stdout/stderr unavailable, process output is disabled\n");
}
else {
((void (*)(id, SEL, id))objc_msgSend)(config,
@selector(setSimulatedApplicationStdOutPath:),
[NSString stringWithUTF8String:path]);
fcntl(STDERR_FILENO, F_GETPATH, &path);
((void (*)(id, SEL, id))objc_msgSend)(config,
@selector(setSimulatedApplicationStdErrPath:),
[NSString stringWithUTF8String:path]);
((void (*)(id, SEL, id))objc_msgSend)(config,
@selector(setSimulatedApplicationStdErrPath:),
[NSString stringWithUTF8String:path]);
}
// Create session.
id session = [[Session alloc] init];