From 0dc7a85acb242ad851c28001435932526a9a6d29 Mon Sep 17 00:00:00 2001 From: Kimmo Suominen Date: Sun, 16 Jul 2000 05:11:46 +0000 Subject: [PATCH] Complete HAVE_MKSTEMP. --- sbr/lock_file.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sbr/lock_file.c b/sbr/lock_file.c index ec88737..2cb6bdc 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -419,9 +419,18 @@ lockit (struct lockinfo *li) curlock = li->curlock; tmplock = li->tmplock; +#ifdef HAVE_MKSTEMP + if ((fd = mkstemp(tmplock)) == -1) + return -1; +#else + if (mktemp(tmplock) == NULL) + return -1; + if (unlink(tmplock) == -1 && errno != ENOENT) + return -1; /* create the temporary lock file */ if ((fd = creat(tmplock, 0600)) == -1) return -1; +#endif #if 0 /* write our process id into lock file */ @@ -501,18 +510,6 @@ lockname (char *file, struct lockinfo *li, int isnewlock) else snprintf (li->tmplock, sizeof(li->tmplock), "%.*s,LCK.XXXXXX", cp - li->curlock, li->curlock); -/* - Mkstemp work postponed until later -Doug -#ifdef HAVE_MKSTEMP - mkstemp (li->tmplock); -#else -*/ - mktemp (li->tmplock); -/* -#endif -*/ - - unlink (li->tmplock); /* remove any stray */ } #endif } -- 1.7.10.4