2013-07-02 5 views
0

NSTask에서 반환 된 데이터를 읽으 려하면 절대로 반환되지 않는 중단이 발생합니다. 실제로 실행중인 스크립트가 stdout 및 stderr로 데이터를 반환하는지 확인했습니다. 이것은 한 줄을 stdout에 보내고 다른 줄을 stderr에 보내는 간단한 두 줄 쉘 스크립트입니다. < NSConcreteFileHandle : 0x10010a800 >readDataToEndOfFile에서 NSTask가 응답하지 않는다

그리고 그냥 달려

NSLog 출력은

있어 핸들을 말한다. 이것은 내가 사용하고있는 코드입니다.

NSPipe *stderr = [NSPipe pipe]; 
    NSPipe *stdout = [NSPipe pipe]; 

    NSTask *task = [[NSTask alloc] init]; 
    task.standardError = stderr; 
    task.standardOutput = stdout; 
    task.standardInput = [NSPipe pipe]; 
    task.launchPath = @"/tmp/f"; 

    [task launchPath]; 
    [task waitUntilExit]; 

    NSFileHandle *fh = [stderr fileHandleForReading]; 

    NSLog(@"Got handle: %@", fh); 

    [fh readDataToEndOfFile]; 

    NSLog(@"Read it"); 

답변

0

실제로 작업을 시작한 적이 없기 때문입니다. 당신은 그냥 문자열로 작업의 경로를 반환

[task launchPath]; 

전화, 실제로 작업을 시작하지 않습니다. 원한다면

[task launch]; 
+0

OMG 당황스러워! – Gargoyle

관련 문제