Allow user to override the temporary directory with the TMPDIR env variable.

(Derived from a FreeBSD patch by Ed Hudson).
This commit is contained in:
jtc 1994-01-03 19:14:18 +00:00
parent 664f968d53
commit 8e39f05b17
3 changed files with 20 additions and 4 deletions

View File

@ -36,7 +36,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)misc.c 5.2 (Berkeley) 2/26/91";*/
static char rcsid[] = "$Id: misc.c,v 1.2 1993/08/01 18:09:55 mycroft Exp $";
static char rcsid[] = "$Id: misc.c,v 1.3 1994/01/03 19:14:18 jtc Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -53,11 +53,21 @@ char *tname = "temporary file"; /* temporary file "name" */
tmp()
{
char *envtmp;
sigset_t set, oset;
static int first;
int fd;
char path[MAXPATHLEN];
bcopy(_PATH_RANTMP, path, sizeof(_PATH_RANTMP));
if (!first) {
envtmp = getenv("TMPDIR");
first = 1;
}
if (envtmp)
(void)sprintf(path, "%s/%s", envtmp, _NAME_RANTMP);
else
bcopy(_PATH_RANTMP, path, sizeof(_PATH_RANTMP));
sigemptyset(&set);
sigaddset(&set, SIGHUP);

View File

@ -31,7 +31,8 @@
* SUCH DAMAGE.
*
* from: @(#)pathnames.h 5.2 (Berkeley) 4/16/91
* $Id: pathnames.h,v 1.2 1993/08/01 18:09:56 mycroft Exp $
* $Id: pathnames.h,v 1.3 1994/01/03 19:14:20 jtc Exp $
*/
#define _NAME_RANTMP "ranlib.XXXXXX"
#define _PATH_RANTMP "/tmp/ranlib.XXXXXX"

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ranlib.1 6.7 (Berkeley) 5/9/91
.\" $Id: ranlib.1,v 1.2 1993/08/01 07:29:45 mycroft Exp $
.\" $Id: ranlib.1,v 1.3 1994/01/03 19:14:21 jtc Exp $
.\"
.Dd May 9, 1991
.Dt RANLIB 1
@ -70,6 +70,11 @@ This is also useful after using the
option of
.Xr make 1 .
.El
.Sh ENVIRONMENT
.Bl -tag -width TMPDIR -compact
.It Ev TMPDIR
The pathname of the directory to use when creating temporary files.
.El
.Sh FILES
.Bl -tag -width /tmp/ranlib.XXXXXX -compact
.It Pa /tmp/ranlib.XXXXXX