Tcl Source Code

Check-in [47248c347c]
Login

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

Overview
Comment:Lash-up to try to deal with [Bug 1224888].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-1224888
Files: files | file ages | folders
SHA1: 47248c347c34e69129208ff4e1eb4b98fb461e60
User & Date: dkf 2011-10-13 12:10:35
Context
2011-10-13
12:16
A little more resilience. check-in: 9856078e30 user: dkf tags: bug-1224888
12:10
Lash-up to try to deal with [Bug 1224888]. check-in: 47248c347c user: dkf tags: bug-1224888
07:56
revert test-case change from [Bug 2935503] check-in: 80c27dee1f user: jan.nijtmans tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to unix/tclUnixFile.c.

8
9
10
11
12
13
14



15
16
17
18
19
20
21
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tclInt.h"
#include "tclPort.h"




static int NativeMatchType(CONST char* nativeName, Tcl_GlobTypeData *types);


/*
 *---------------------------------------------------------------------------
 *







>
>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tclInt.h"
#include "tclPort.h"
#ifndef NO_DLFCN_H
#include <dlfcn.h>
#endif

static int NativeMatchType(CONST char* nativeName, Tcl_GlobTypeData *types);


/*
 *---------------------------------------------------------------------------
 *
45
46
47
48
49
50
51












52
53
54
55
56
57
58


















59
60
61
62
63
64
65
    CONST char *argv0;		/* The value of the application's argv[0]
				 * (native). */
{
    CONST char *name, *p;
    Tcl_StatBuf statBuf;
    int length;
    Tcl_DString buffer, nameString;













    if (argv0 == NULL) {
	return NULL;
    }
    if (tclNativeExecutableName != NULL) {
	return tclNativeExecutableName;
    }



















    Tcl_DStringInit(&buffer);

    name = argv0;
    for (p = name; *p != '\0'; p++) {
	if (*p == '/') {
	    /*







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







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







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
    CONST char *argv0;		/* The value of the application's argv[0]
				 * (native). */
{
    CONST char *name, *p;
    Tcl_StatBuf statBuf;
    int length;
    Tcl_DString buffer, nameString;
#ifndef DJGPP
    int i;
    static CONST char *exepaths[] = {
      "/proc/self/exe", "/proc/%lu/exe", "/proc/%lu/file",
      "/proc/%lu/object/a.out"
    };
    char buf1[PATH_MAX+1], buf2[128];
#endif
#ifndef NO_DLFCN_H
    Dl_info dlinfoBuffer;
    void *sym;
#endif

    if (argv0 == NULL) {
	return NULL;
    }
    if (tclNativeExecutableName != NULL) {
	return tclNativeExecutableName;
    }

#ifndef DJGPP
    for (i=0 ; i<sizeof(exepaths)/sizeof(*exepaths) ; i++) {
	sprintf(buf2,exepaths[i],(unsigned long)getpid());
	if (readlink(buf2,buf1,PATH_MAX) > 0 && buf1[0] == '/') {
	    name = buf1;
	    goto gotName;
	}
    }
#endif
#ifndef NO_DLFCN_H
    sym = dlsym(RTLD_DEFAULT, "_main");
    if (sym != NULL && dladdr(sym, &dlinfoBuffer)
	    && dlinfoBuffer.dli_fname[0] == '/') {
	name = dlinfoBuffer.dli_fname;
	goto gotName;
    }
#endif

    Tcl_DStringInit(&buffer);

    name = argv0;
    for (p = name; *p != '\0'; p++) {
	if (*p == '/') {
	    /*