Reputation: 4073
I've created a file by using mkfifo /tmp/my.fifo
. I now want to write chars into the file (with Objective C) to be able to grab them by tail -f /tmp/my.fifo
.
For some reason this does not work. The tail command only displays one character, and then stops output.
Objective C Code:
NSError *error = nil;
[buffer writeToFile:@"/tmp/my.fifo" atomically:YES encoding:NSUTF8StringEncoding error:&error];
if(error){
NSLog(@"Fail: %@",[error localizedDescription]);
}
The NSLog does not output anything. So from Objective C perspective theres obviously no error.
Upvotes: 1
Views: 512
Reputation: 4073
Solution was simpler than I thought:
NSFileHandle *fileHandle=[NSFileHandle fileHandleForWritingAtPath:@"/tmp/my.fifo"];
[fileHandle seekToEndOfFile];
[fileHandle writeData:[buffer dataUsingEncoding:NSUTF8StringEncoding]];
[fileHandle closeFile];
Upvotes: 2