roslaunch prevents node from creating/writing to file
For our current project, we created a launch file that initializes several nodes, one of which is supposed to create a log file, open it, write a header line at the beginning of the file, and then close the file.
When we run the nodes individually from terminal, this function works fine, but when the project is run from a launch file, the log file is never created. Do nodes run from a launch file not have permission to create new log files?
Function to create log file:
char Beacon::createLogFile(char *logDataFileName)
{
int status;
status = mkdir("Log", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (status == -1)
{
// error; it might be that the directory already exists
if (errno == EEXIST)
{
// no problem
}
else if (errno == EACCES)
{
printf("Permission\n");
return 1;
}
}
else
{
// Directory successfully created
}
FILE* logData_f_stream;
logData_f_stream = fopen(logDataFileName, "w");
fprintf(logData_f_stream, "NodeID Latitude Longitude Time OWTT\n");
fclose(logData_f_stream);
return 0;
}