peter@baylor.UUCP (Peter da Silva) (08/19/85)
If tempnam/mktemp does anything more than sprintf(fname, "/tmp/tmp%d%d", getpid(), cnt++), what it does escapes me. Perhaps someone out there could tell me how 2 processes can have the same pid? I deem to be missing something. -- Peter da Silva (the mad Australian werewolf) UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter MCI: PDASILVA; CIS: 70216,1076
keesan@bbncc5.UUCP (Morris M. Keesan) (08/21/85)
In article <458@baylor.UUCP> peter@baylor.UUCP (Peter da Silva) writes: >If tempnam/mktemp does anything more than sprintf(fname, "/tmp/tmp%d%d", >getpid(), cnt++), what it does escapes me. mktemp returns a file name that is guaranteed not to exist (modulo race conditions), which affords you some protection against bozos who are making temp files using rand() instead of getpid(), e.g. -- Morris M. Keesan keesan@bbn-unix.ARPA {decvax,ihnp4,etc.}!bbncca!keesan
dave@andromeda.UUCP (Dave Bloom) (08/21/85)
In article <458@baylor.UUCP>, peter@baylor.UUCP (Peter da Silva) writes: > If tempnam/mktemp does anything more than sprintf(fname, "/tmp/tmp%d%d", > getpid(), cnt++), what it does escapes me. Perhaps someone out there could > tell me how 2 processes can have the same pid? I deem to be missing something. A tempfile from a previous go-around of pid's that was never removed could be lying around (although it is unlikely). In that case the tempfile name might not be unique. I'm sure with enough use it DOES happen! _______________________________________________________________________________ UUCP: {allegra, seismo}!topaz!andromeda!dave Dave Bloom WORK: (201) 648-5083 HOME: (201) 868-1764 "You're never alone with a schizophrenic...."
tim@cithep.UucP (Tim Smith ) (08/25/85)
> If tempnam/mktemp does anything more than sprintf(fname, "/tmp/tmp%d%d", > getpid(), cnt++), what it does escapes me. Perhaps someone out there could > tell me how 2 processes can have the same pid? I deem to be missing something. Well, in the above, a proc with pid 10 creating 11 temp files will collide with a proc with pid 101 creating 1 temp file. Perhaps "/tmp/tmp%d.%d" would be better. -- unlk a6 rts Tim Smith ihnp4!{wlbr!callan,cithep}!tim