Tcl Source Code

Check-in [dbb6880cd2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Backport from Tcl 8.6. * unix/tclUnixPipe.c (DefaultTempDir): [Bug 2933003]: Allow overriding of the back-stop default temporary file location at compile time by setting the TCL_TEMPORARY_FILE_DIRECTORY #def to a string containing the directory name (defaults to "/tmp" as that is the most common default).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: dbb6880cd242d8dc084c96f8e9ac3d727bd6ceef
User & Date: dkf 2012-11-14 14:29:29
Context
2012-11-14
16:30
Fix botched patch check-in: 61699305b8 user: dkf tags: core-8-4-branch
14:33
* unix/tclUnixPipe.c (DefaultTempDir): [Bug 2933003]: Allow overriding of the back-stop default te...
check-in: 4fb4ed1471 user: dkf tags: core-8-5-branch
14:29
Backport from Tcl 8.6. * unix/tclUnixPipe.c (DefaultTempDir): [Bug 2933003]: Allow overriding of t... check-in: dbb6880cd2 user: dkf tags: core-8-4-branch
09:07
Workaround for mingw versions which don't provide _fpcontrol in float.h check-in: 4a2030278d user: jan.nijtmans tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.









1
2
3
4
5
6
7








2012-11-07  Don Porter  <[email protected]>

	* win/tclWinSock.c:	[Bug 3574493] Avoid hanging on exit due to
	use of synchronization calls in routines called by DllMain().

2012-10-03  Don Porter  <[email protected]>

>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2012-11-14  Donal K. Fellows  <[email protected]>

	* unix/tclUnixPipe.c (DefaultTempDir): [Bug 2933003]: Allow overriding
	of the back-stop default temporary file location at compile time by
	setting the TCL_TEMPORARY_FILE_DIRECTORY #def to a string containing
	the directory name (defaults to "/tmp" as that is the most common
	default).

2012-11-07  Don Porter  <[email protected]>

	* win/tclWinSock.c:	[Bug 3574493] Avoid hanging on exit due to
	use of synchronization calls in routines called by DllMain().

2012-10-03  Don Porter  <[email protected]>

Changes to unix/tclUnixPipe.c.

195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
    Tcl_DString dstring;
    int fd;

    /*
     * We should also check against making more then TMP_MAX of these.
     */

    strcpy(fileName, P_tmpdir);				/* INTL: Native. */
    if (fileName[strlen(fileName) - 1] != '/') {
	strcat(fileName, "/");				/* INTL: Native. */
    }
    strcat(fileName, "tclXXXXXX");
    fd = mkstemp(fileName);				/* INTL: Native. */
    if (fd == -1) {
	return NULL;







|







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
    Tcl_DString dstring;
    int fd;

    /*
     * We should also check against making more then TMP_MAX of these.
     */

    strcpy(fileName, DefaultTempDir());			/* INTL: Native. */
    if (fileName[strlen(fileName) - 1] != '/') {
	strcat(fileName, "/");				/* INTL: Native. */
    }
    strcat(fileName, "tclXXXXXX");
    fd = mkstemp(fileName);				/* INTL: Native. */
    if (fd == -1) {
	return NULL;
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269






































270
271
272
273
274
275
276
    Tcl_Obj *result = NULL;
    int fd;

    /*
     * We should also check against making more then TMP_MAX of these.
     */

    strcpy(fileName, P_tmpdir);		/* INTL: Native. */
    if (fileName[strlen(fileName) - 1] != '/') {
	strcat(fileName, "/");		/* INTL: Native. */
    }
    strcat(fileName, "tclXXXXXX");
    fd = mkstemp(fileName);		/* INTL: Native. */
    if (fd == -1) {
	return NULL;
    }
    fcntl(fd, F_SETFD, FD_CLOEXEC);
    unlink(fileName);			/* INTL: Native. */

    result = TclpNativeToNormalized((ClientData) fileName);
    close (fd);
    return result;
}







































/*
 *----------------------------------------------------------------------
 *
 * TclpCreatePipe --
 *
 *      Creates a pipe - simply calls the pipe() function.







|















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
    Tcl_Obj *result = NULL;
    int fd;

    /*
     * We should also check against making more then TMP_MAX of these.
     */

    strcpy(fileName, DefaultTempDir());	/* INTL: Native. */
    if (fileName[strlen(fileName) - 1] != '/') {
	strcat(fileName, "/");		/* INTL: Native. */
    }
    strcat(fileName, "tclXXXXXX");
    fd = mkstemp(fileName);		/* INTL: Native. */
    if (fd == -1) {
	return NULL;
    }
    fcntl(fd, F_SETFD, FD_CLOEXEC);
    unlink(fileName);			/* INTL: Native. */

    result = TclpNativeToNormalized((ClientData) fileName);
    close (fd);
    return result;
}

/*
 *----------------------------------------------------------------------
 *
 * DefaultTempDir --
 *
 *	Helper that does *part* of what tempnam() does.
 *
 *----------------------------------------------------------------------
 */

static const char *
DefaultTempDir(void)
{
    const char *dir;
    struct stat buf;

    dir = getenv("TMPDIR");
    if (dir && dir[0] && stat(dir, &buf) == 0 && S_ISDIR(buf.st_mode)
	    && access(dir, W_OK)) {
	return dir;
    }

#ifdef P_tmpdir
    dir = P_tmpdir;
    if (stat(dir, &buf) == 0 && S_ISDIR(buf.st_mode) && access(dir, W_OK)) {
	return dir;
    }
#endif

    /*
     * Assume that the default location ("/tmp" if not overridden) is always
     * an existing writable directory; we've no recovery mechanism if it
     * isn't.
     */

    return TCL_TEMPORARY_FILE_DIRECTORY;
}

/*
 *----------------------------------------------------------------------
 *
 * TclpCreatePipe --
 *
 *      Creates a pipe - simply calls the pipe() function.