Unix Programming - Does kill() remove temporary files?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > August 2007 > Does kill() remove temporary files?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Does kill() remove temporary files?
Army1987

2007-08-23, 7:21 am

If process 1234 creates a temporary file with tmpfile(), and another
process calls kill(1234, SIGTERM), does the temporary file get
deleted?
--
Army1987 (Replace "NOSPAM" with "email")
No-one ever won a game by resigning. -- S. Tartakower

SM Ryan

2007-08-23, 7:21 am

Army1987 <army1987@NOSPAM.it> wrote:
# If process 1234 creates a temporary file with tmpfile(), and another
# process calls kill(1234, SIGTERM), does the temporary file get
# deleted?

All kill does is send a signal to process. What happens to the
resources of the process, including open files, depends on what
the process does. If the process exits, all of its open files
are closed; if this was the last open descriptor of an unlinked
file, the file is deleted. If the process doesn't exit nor close
its files, or a child shares the file descriptor, the file remains
open and continues to exist whether linked or not.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
If your job was as meaningless as theirs, wouldn't you go crazy too?
David Schwartz

2007-08-23, 7:21 am

On Aug 23, 3:25 am, Army1987 <army1...@NOSPAM.it> wrote:

> If process 1234 creates a temporary file with tmpfile(), and another
> process calls kill(1234, SIGTERM), does the temporary file get
> deleted?


Yes, assuming no other process has a reference to that file.

DS

Gary R. Schmidt

2007-08-23, 1:27 pm

David Schwartz wrote:

> On Aug 23, 3:25 am, Army1987 <army1...@NOSPAM.it> wrote:
>
>
>
>
> Yes, assuming no other process has a reference to that file.
>

I'd say, "maybe".

Solaris 10, "man tmpfile":
....
USAGE
The stream refers to a file which is unlinked. If the pro-
cess is killed in the period between file creation and
unlinking, a permanent file may be left behind.

Cheers,
Gary B-)

--
________________________________________
______________________________________
Armful of chairs: Something some people would not know
whether you were up them with or not
- Barry Humphries
David Schwartz

2007-08-23, 7:21 pm

On Aug 23, 6:50 am, "Gary R. Schmidt" <grschm...@acm.org> wrote:
> David Schwartz wrote:
>
>
>
> I'd say, "maybe".
>
> Solaris 10, "man tmpfile":
> ...
> USAGE
> The stream refers to a file which is unlinked. If the pro-
> cess is killed in the period between file creation and
> unlinking, a permanent file may be left behind.


I disagree, but on a technicality. Until the unlink has completed, the
process has not created a *temporary* file. The question presumed the
process had already created a temporary file.

DS


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com