Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!feeds.phibee-telecom.net!usenet.ukfsn.org!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: single instance Date: Sat, 5 Jan 2013 17:43:15 +0000 (UTC) Organization: UK Free Software Network Lines: 36 Message-ID: References: NNTP-Posting-Host: 84.45.235.129 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: localhost.localdomain 1357407795 12073 84.45.235.129 (5 Jan 2013 17:43:15 GMT) X-Complaints-To: usenet@localhost.localdomain NNTP-Posting-Date: Sat, 5 Jan 2013 17:43:15 +0000 (UTC) User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Xref: csiph.com comp.lang.java.programmer:20990 On Sat, 05 Jan 2013 12:48:41 +0000, Chris Uppal wrote: > There may be something added to modern Linux (or whatever) that makes it > easier to create shared temporary files (not the requirement here, of > course). But there's nothing in "classic" *NIX (say from around the > time of SysV). > Correct: test C code written and checked to prove your point. The Stratus VOS OS left the file in place: you could see it from list_directory after it had been deleted, but Linux doesn't do that. However, the automatic cleanup is easy enough to manage from C via the atexit() function, which is very to use since you just call atexit() near the start of the main() function: once atexit() has registered your exit action(s) you get on with whatever the program is meant to do in the knowledge that these actions will happen regardless of how the program exits (power failures and system crashes excluded). This works for Linux and all Unices since SVR4. atexit() is documented in the O'Reilly Lion book. The current kernel 3.6 Linux manpage says atexit() conforms to SVR4, 4.3BSD, C89, C99 and POSIX.1-2001. It looks as though the nearest we can come to this in Java is via try...finally blocks. However, I'm wondering if the finally block would always execute, e.g. if the try...finally block is in the main() method of a program that exits leaving thread(s) running to do the work, does the finally block still get still run when the last thread(s) terminates? I had a fairly cursory look at JLS 14.20.1 but it wasn't clear on this point. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |