Secure temporary file: Difference between revisions

Content added Content deleted
(Added PicoLisp)
Line 138: Line 138:
// open $filename and do stuff with it</lang>
// open $filename and do stuff with it</lang>


=={{header|PicoLisp}}==
The 'tmp' function returns temporary file names which are exclusively for the
current process (based on the process ID). These files are automatically deleted
upon process termination. Background tasks within a single PicoLisp process is
always non-preemptive, therefore dedicated locks are usually not necessary. If
they are (e.g. because such a file name is passed to a child process), explicit
locks with the 'ctl' functions are possible.
<lang PicoLisp>: (out (tmp "foo") (println 123)) # Write tempfile
-> 123

: (in (tmp "foo") (read)) # Read tempfile
-> 123

: (let F (tmp "foo")
(ctl F # Get exclusive lock
(let N (in F (read)) # Atomic increment
(out F (println (inc N))) ) ) )
-> 124</lang>


=={{header|PureBasic}}==
=={{header|PureBasic}}==