If your program creates directories that behave like /tmp, in that lots of people put things there but shouldn't be able to remove each other's files, then you should set the sticky bit on the directory.
$ chmod o+t directory
chmod (dir_path, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);