Calling rm and unlink from C++ on Solaris 10
Posted on 2011-02-22
We are having a problem consistently deleting files on a solaris 10 system. Briefly, we start a process which starts multiple other processes. These processes run as root. I'm not sure why. This is a legasy system and there is LOTS that is not clear. But I digress.
These root processes delete (using unlink) some files and then recreate them. When I do a run, SOMTIMES the user/group of these files is "nobody users" and SOMETIMES the user/group of these files is "dave users". We don't yet know why this happens.
The problem is that from run to run the files that are supposed to get deleted and then created again do not always get deleted. This is obviously because the owner is not correct. So unlink is not doing what we need, deleting the files no matter what.
If, from a shell in the terminal window, I issue an "rm" command, I will get a y/n prompt and the file will be deleted if I say "y".
I am changing the code to do a system call to do an "rm -f", but I'm not really happy with this. Anyone have any idea what might be going on?
PS - I don't know how this ended up in the Web Development/PHP zone. It wasn't supposed to. Just ignore, if you can.