Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 NSTask 处理从标准输入传递的参数。参数通过NSFileHandle.
NSFileHandle
它工作正常,但我们的命令行工具从标准输入读取输入,直到它接收到 EOF 符号(通过按 Ctrl+C)。
我认为我不能将 EOF 符号添加到 ASCII 字符串中,那么选项是什么?任何反馈表示赞赏!
提前致谢!
在管道的写入端调用closeFileEOF 条件:
closeFile
NSPipe *inPipe = [NSPipe new]; [task setStandardInput:inPipe]; [[inPipe fileHandleForWriting] writeData:...]; // ... [[inPipe fileHandleForWriting] closeFile];