I have a part of C program:
char buf[256];
fprintf(stderr, "buf created. going to freopen. Path:\n");
fprintf(stderr, path);
fprintf(stderr, "\n");
if (!freopen(path, "a", stderr)) {
fprintf(stderr, "if entered\n");
fprintf(stderr, "Can't redirect stderr\n");
sprintf(buf, "Server can't open log file (%s)", path);
fprintf(stderr, "sprintf ok. going to send_message\n");
send_message(buf, config.maintenance_delay);
fprintf(stderr, "send_message ok\n");
exit(1);
}
fprintf(stderr, "ndef USING_FCGI, ended\n");
And the output for it is:
buf created. going to freopen. Path:
../log_andrewwhynot/scheduler.log
Segmentation fault
So, I assume the problem is in the freopen() function but I'm unable to figure out what is wrong with it. I've double-checked the path to the file (it exists and everything is ok with access rights) and even tried to hardcode the absolute path or use path to another file, but everything was in vain. Then, I tried to open the file for write action instead of append, but it did not help as well. So, what might be wrong? Why does the call cause SIGSEGV?
Thank you!
Architecture: arm64
OS: armbian nightly 5.41.180312
gcc version: (Ubuntu GLIBC 2.23-0ubuntu10) 2.23