3 ms·
Your process can always segfault, or the machine lose power. A more robust way of handling this kind of thing is to always clean up the leftovers from previous
by hossbeast 9y ago
Your process can always segfault, or the machine lose power. A more robust way of handling this kind of thing is to always clean up the leftovers from previous runs, at the start of the program. This also has the advantage that the state from the most recent run is always available, for debugging / analysis.
Also on linux, you can use unnamed temp files, see O_TMPFILE in http://man7.org/linux/man-pages/man2/open.2.html http://man7.org/linux/man-pages/man2/open.2.html
- jwilk 9y agoHow do you use O_TMPFILE from a shell script?
- hossbeast 9y agoYou can't use it directly from bash, but its readily available in perl, with the POSIX module. Even in bash, you can unlink your temp files before you use them, and pass them around by file descriptor rather than by name.
- jwilk 9y ago> its readily available in perl, with the POSIX module Oh? I don't see anything like this in the Perl codebase. On the other hand, O_TMPFILE is available in Python since 3.4: https://docs.python.org/3/whatsnew/3.4.html#os https://docs.python.org/3/whatsnew/3.4.html#os