9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] mkstemp()
@ 2005-01-31  8:29 cej
  0 siblings, 0 replies; 15+ messages in thread
From: cej @ 2005-01-31  8:29 UTC (permalink / raw)
  To: 9fans

Thank you all for patience with my questions, and for help!
 
++pac.
 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-29 10:11             ` arisawa
@ 2005-01-29 15:11               ` Russ Cox
  0 siblings, 0 replies; 15+ messages in thread
From: Russ Cox @ 2005-01-29 15:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> By the way,  I don't know what to do: assume I find a "listen" is
> listening a port
> that I don't intended to listen.
> I will fix some files in /rc/bin/service/ and then I will want to kill
> the "listen".
> But how to find the pid ?

There's not a good way.  You could kill all the listeners
and then restart aux/listen though.

Russ


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-29  9:11           ` Russ Cox
@ 2005-01-29 10:11             ` arisawa
  2005-01-29 15:11               ` Russ Cox
  0 siblings, 1 reply; 15+ messages in thread
From: arisawa @ 2005-01-29 10:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello Russ

> To find out what is being used in /tmp, grep /tmp /proc/*/fd.
>

Oh thanks. That's very nice!

By the way,  I don't know what to do: assume I find a "listen" is 
listening a port
that I don't intended to listen.
I will fix some files in /rc/bin/service/ and then I will want to kill 
the "listen".
But how to find the pid ?

Kenji Arisawa





^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-29  7:23         ` arisawa
@ 2005-01-29  9:11           ` Russ Cox
  2005-01-29 10:11             ` arisawa
  0 siblings, 1 reply; 15+ messages in thread
From: Russ Cox @ 2005-01-29  9:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I hope temporal filename is made clear so that I can safely remove
> files that are no longer required .
> In my /tmp, there are many temporal files that is created by acme
> and others.
> I hesitate whether I can safely remove these annoying files.

If you log in and don't start any programs, then it's safe
to remove everything in /tmp (unless you have precious data
stored there!).

To find out what is being used in /tmp, grep /tmp /proc/*/fd.

Russ


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-29  3:07     ` boyd, rounin
  2005-01-29  3:15       ` Russ Cox
@ 2005-01-29  8:30       ` geoff
  1 sibling, 0 replies; 15+ messages in thread
From: geoff @ 2005-01-29  8:30 UTC (permalink / raw)
  To: 9fans

No, removing the open file is a Unix idiom.

On Plan 9, create your temporaries with the ORCLOSE bit and they'll be
removed when closed, including if the application crashes or the
client machine crashes (but not, alas, if the file server is halted
with the file still open, at least in ken fs).  Or run ramfs first.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-29  3:15       ` Russ Cox
@ 2005-01-29  7:23         ` arisawa
  2005-01-29  9:11           ` Russ Cox
  0 siblings, 1 reply; 15+ messages in thread
From: arisawa @ 2005-01-29  7:23 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

I hope temporal filename is made clear so that I can safely remove
files that are no longer required .
In my /tmp, there are many temporal files that is created by acme
and others.
I hesitate whether I can safely remove these annoying files.

Kenji Arisawa



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-29  3:07     ` boyd, rounin
@ 2005-01-29  3:15       ` Russ Cox
  2005-01-29  7:23         ` arisawa
  2005-01-29  8:30       ` geoff
  1 sibling, 1 reply; 15+ messages in thread
From: Russ Cox @ 2005-01-29  3:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> other deal is to remove the file, freeing up the name after its creation (if i have my 9P right).

if you remove the file, it's up to the file server
whether you can still access it with the open fd.
the plan 9 disk file servers (kfs, ken fs, fossil) don't let you.

russ


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-29  3:02   ` Scott Schwartz
@ 2005-01-29  3:07     ` boyd, rounin
  2005-01-29  3:15       ` Russ Cox
  2005-01-29  8:30       ` geoff
  0 siblings, 2 replies; 15+ messages in thread
From: boyd, rounin @ 2005-01-29  3:07 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

other deal is to remove the file, freeing up the name after its creation (if i have my 9P right).
--
MGRS 31U DQ 52572 12604




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-28 13:44 ` Gorka Guardiola Múzquiz
@ 2005-01-29  3:02   ` Scott Schwartz
  2005-01-29  3:07     ` boyd, rounin
  0 siblings, 1 reply; 15+ messages in thread
From: Scott Schwartz @ 2005-01-29  3:02 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

| Creating a name with a random number in /tmp like /tmp/acme.paurea.987987 
| wouldn't suffice?. Given we have private namespaces and random numbers
| normally don't collide /tmp/acme.234234 or even /tmp/23234234 would probably 
| suffice too.

But still, it's nice to have a general solution.  Sometimes you do need
to create a file in a shared space.  One could even imagine a fileserver
that filled in the filename for you, rather like the special purpose
ones under /net.  In general you probably don't want to reserve the name
"clone", but "..." or "" might be ok.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-28 16:08   ` Gorka Guardiola Múzquiz
@ 2005-01-28 16:16     ` Russ Cox
  0 siblings, 0 replies; 15+ messages in thread
From: Russ Cox @ 2005-01-28 16:16 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> What about two instances of the same program?. What I meant in my other mail
> is that a big random number would probably suffice, as the probability of
> collision is really low
> (as you say we already have user separation).
> Even more if it has an identifier per applications (ex. /tmp/acme.23423)
> which also makes the name readable. In any case, if the create fails, you
> can always generate the
> random number again.

which is exactly what mkstemp does.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-28 15:38 ` Ronald G. Minnich
@ 2005-01-28 16:08   ` Gorka Guardiola Múzquiz
  2005-01-28 16:16     ` Russ Cox
  0 siblings, 1 reply; 15+ messages in thread
From: Gorka Guardiola Múzquiz @ 2005-01-28 16:08 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

What about two instances of the same program?. What I meant in my other mail 
is that a big random number would probably suffice, as the probability of 
collision is really low
(as you say we already have user separation).
Even more if it has an identifier per applications (ex. /tmp/acme.23423) 
which also makes the name readable. In any case, if the create fails, you 
can always generate the
random number again.

----- Original Message ----- 
From: "Ronald G. Minnich" <rminnich@lanl.gov>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Sent: Friday, January 28, 2005 4:38 PM
Subject: Re: [9fans] mkstemp()


>
>
> On Fri, 28 Jan 2005 cej@gli.cas.cz wrote:
>
>> need mkstemp() [BSD unistd.h]
>
> why? Your tmp is not my tmp. I see no need for the actual function, just
> make something with the same name that doesn't worry about 'unique' file
> names.
>
> ron
> 



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-28 13:39 cej
  2005-01-28 13:44 ` Gorka Guardiola Múzquiz
  2005-01-28 15:05 ` Russ Cox
@ 2005-01-28 15:38 ` Ronald G. Minnich
  2005-01-28 16:08   ` Gorka Guardiola Múzquiz
  2 siblings, 1 reply; 15+ messages in thread
From: Ronald G. Minnich @ 2005-01-28 15:38 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs



On Fri, 28 Jan 2005 cej@gli.cas.cz wrote:

> need mkstemp() [BSD unistd.h]

why? Your tmp is not my tmp. I see no need for the actual function, just 
make something with the same name that doesn't worry about 'unique' file 
names. 

ron


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-28 13:39 cej
  2005-01-28 13:44 ` Gorka Guardiola Múzquiz
@ 2005-01-28 15:05 ` Russ Cox
  2005-01-28 15:38 ` Ronald G. Minnich
  2 siblings, 0 replies; 15+ messages in thread
From: Russ Cox @ 2005-01-28 15:05 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Enjoy.

int
mkstemp(char *template)
{
    char *s;
    int i, fd;

    s = strdup(template);
    if(s == nil)
        return -1;
    for(i=0; i<20; i++){
        strcpy(s, template);
        mktemp(s);
        if((fd = create(s, ORDWR|OEXCL, 0666)) >= 0){
            strcpy(template, s);
            free(s);
            return fd;
        }
    }
    free(s);
    return -1;
}

On Fri, 28 Jan 2005 14:39:41 +0100, cej@gli.cas.cz <cej@gli.cas.cz> wrote:
> need mkstemp() [BSD unistd.h]
> any better idea than to copy the code from BSD | GNU ?
> (I understand that returns a fd of a temp file)
> 
> thanks,
> ++pac.
> 
>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [9fans] mkstemp()
  2005-01-28 13:39 cej
@ 2005-01-28 13:44 ` Gorka Guardiola Múzquiz
  2005-01-29  3:02   ` Scott Schwartz
  2005-01-28 15:05 ` Russ Cox
  2005-01-28 15:38 ` Ronald G. Minnich
  2 siblings, 1 reply; 15+ messages in thread
From: Gorka Guardiola Múzquiz @ 2005-01-28 13:44 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Creating a name with a random number in /tmp like /tmp/acme.paurea.987987 
wouldn't suffice?. Given we have private namespaces and random numbers
normally don't collide /tmp/acme.234234 or even /tmp/23234234 would probably 
suffice too.
----- Original Message ----- 
From: <cej@gli.cas.cz>
To: <9fans@cse.psu.edu>
Sent: Friday, January 28, 2005 2:39 PM
Subject: [9fans] mkstemp()


> need mkstemp() [BSD unistd.h]
> any better idea than to copy the code from BSD | GNU ?
> (I understand that returns a fd of a temp file)
>
> thanks,
> ++pac.
>
> 



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [9fans] mkstemp()
@ 2005-01-28 13:39 cej
  2005-01-28 13:44 ` Gorka Guardiola Múzquiz
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: cej @ 2005-01-28 13:39 UTC (permalink / raw)
  To: 9fans

need mkstemp() [BSD unistd.h]
any better idea than to copy the code from BSD | GNU ?
(I understand that returns a fd of a temp file)
 
thanks,
++pac.
 

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-01-31  8:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-31  8:29 [9fans] mkstemp() cej
  -- strict thread matches above, loose matches on Subject: below --
2005-01-28 13:39 cej
2005-01-28 13:44 ` Gorka Guardiola Múzquiz
2005-01-29  3:02   ` Scott Schwartz
2005-01-29  3:07     ` boyd, rounin
2005-01-29  3:15       ` Russ Cox
2005-01-29  7:23         ` arisawa
2005-01-29  9:11           ` Russ Cox
2005-01-29 10:11             ` arisawa
2005-01-29 15:11               ` Russ Cox
2005-01-29  8:30       ` geoff
2005-01-28 15:05 ` Russ Cox
2005-01-28 15:38 ` Ronald G. Minnich
2005-01-28 16:08   ` Gorka Guardiola Múzquiz
2005-01-28 16:16     ` Russ Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).