I'm unable to run this piece of code which writes the pid to a file.
NSString *text = [NSString stringWithFormat:@"%d\n", getpid()];
NSError *error = nil;
if (![text writeToFile:@"/tmp/Frontend.pid" atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
NSLog(@"Cannot write PID file %@: %@", @"/tmp/Frontend.pid", error);
return NO;
}
This is the error I get.
2017-11-13 20:19:18.742171+0530 TestThread[7648:273326] Cannot write PID file /tmp/Frontend.pid: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “Frontend.pid” in the folder “tmp”." UserInfo={NSFilePath=/tmp/Frontend.pid, NSUnderlyingError=0x6040000432a0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
I've changed the permission for the directory to 777 and it still doesn't have enough permissions. Please help.
Well, I finally fixed it. Here is the default configuration of a new project in xcode which ruined the whole file io thing. I turned off these 2 knobs in the entitlements file and was good to go.