home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 4042 < prev    next >
Encoding:
Text File  |  1992-07-31  |  1.1 KB  |  37 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!ucla-cs!ratner
  3. From: ratner@ficus.cs.ucla.edu (David Ratner)
  4. Subject: Re: /tmp files
  5. Message-ID: <ratner.712606467@ficus.cs.ucla.edu>
  6. Sender: usenet@cs.ucla.edu (Mr Usenet)
  7. Nntp-Posting-Host: ipswich.cs.ucla.edu
  8. Organization: UCLA, Computer Science Department
  9. References: <1992Jul31.095122@is.morgan.com>
  10. Date: 31 Jul 92 18:14:27 GMT
  11. Lines: 24
  12.  
  13. scairns@is.morgan.com writes:
  14.  
  15.  
  16. >Is there a system call to randomly generate unique file names
  17. >in /tmp?  
  18.  
  19. >Or alternatively, anyone have any code examples which do this?
  20.  
  21. >I need to send output temporarily to a unique file in /tmp, do some
  22. >work with it and than discard it.
  23.  
  24. >Thanks in advance.
  25.  
  26. Usually, people use the process-id of the running process and append that
  27. to some set string to get a unique, temporary filename.  (The process-id
  28. is guarranteed to be unique until the program exits).
  29. Use getpid() to get the process id.
  30.  
  31. Dave 
  32. --
  33. * *  ***  *     *    |   Dave "Van Damme" Ratner
  34. * *  *    *    * *  / \  ratner@cs.ucla.edu
  35. * *  *    *    ***  \ /  
  36. ***  ***  ***  * *   |   "Wham Bam, thank you Van Damme!"    
  37.