Check-in [013d6b36f4]
Overview
Comment:Updated to use "/proc/self/exe" rather than "/proc/<pid>/exe"

Updated to check for "/proc/curproc/file" (FreeBSD)

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:013d6b36f4f4223a937b04b8a872164a9ec92545
User & Date: rkeene on 2010-09-26 04:50:35
Other Links: manifest | tags
Context
2010-09-26
04:50
Added first draft of kitdll check-in: 029b69f827 user: rkeene tags: trunk
04:50
Updated to use "/proc/self/exe" rather than "/proc/<pid>/exe"

Updated to check for "/proc/curproc/file" (FreeBSD) check-in: 013d6b36f4 user: rkeene tags: trunk

04:50
Updated to remove kitdll from releases since it is currently incomplete check-in: 914a6c9397 user: rkeene tags: trunk
Changes

Modified kitsh/buildsrc/kitsh-0.0/configure.ac from [e12a8b84bb] to [d545ae6633].

    39     39   AC_CHECK_FUNCS(Tcl_SetStartupScript TclSetStartupScriptPath)
    40     40   dnl Check for the ability to get the current system encoding
    41     41   AC_CHECK_FUNCS(Tcl_GetEncodingNameFromEnvironment Tcl_SetSystemEncoding)
    42     42   LIBS="${SAVE_LIBS}"
    43     43   
    44     44   dnl Check for optional headers
    45     45   AC_HEADER_STDC
    46         -AC_CHECK_HEADERS(unistd.h)
           46  +AC_CHECK_HEADERS(unistd.h string.h strings.h)
    47     47   
    48     48   dnl Check for optional system calls
    49     49   AC_CHECK_FUNCS(readlink)
    50     50   
    51     51   dnl Check for acceptable dladdr so we can find ourselves on Solaris
    52     52   DC_CHECK_FOR_ACCEPTABLE_DLADDR
    53     53   

Modified kitsh/buildsrc/kitsh-0.0/kitInit.c from [534a43d0fd] to [4d11547632].

    32     32   #endif /* MB_TASKMODAL */
    33     33   
    34     34   #include "tclInt.h"
    35     35   
    36     36   #ifdef HAVE_UNISTD_H
    37     37   #  include <unistd.h>
    38     38   #endif
           39  +#ifdef HAVE_STRING_H
           40  +#  include <string.h>
           41  +#endif
           42  +#ifdef HAVE_STRINGS_H
           43  +#  include <strings.h>
           44  +#endif
    39     45   
    40     46   /* For dladdr() and Dl_info */
    41     47   #ifdef HAVE_DLFCN_H
    42     48   #  include <dlfcn.h>
    43     49   #endif
    44     50   
    45     51   #if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING)
................................................................................
   202    208   
   203    209   static void FindAndSetExecName(Tcl_Interp *interp) {
   204    210   	int len = 0;
   205    211   	Tcl_Obj *execNameObj;
   206    212   	Tcl_Obj *lobjv[1];
   207    213   #ifdef HAVE_READLINK
   208    214   	ssize_t readlink_ret;
   209         -	char procpath[4096];
   210    215   	char exe_buf[4096];
   211         -	int snprintf_ret;
   212    216   #endif /* HAVE_READLINK */
   213    217   #ifdef HAVE_ACCEPTABLE_DLADDR
   214    218   	Dl_info syminfo;
   215    219   	int dladdr_ret;
   216    220   #endif /* HAVE_ACCEPTABLE_DLADDR */ 
   217    221   
   218    222   #ifdef HAVE_READLINK
   219    223   	if (Tcl_GetNameOfExecutable() == NULL) {
   220         -		snprintf_ret = snprintf(procpath, sizeof(procpath), "/proc/%lu/exe", (unsigned long) getpid());
   221         -		if (snprintf_ret < sizeof(procpath)) {
   222         -			readlink_ret = readlink(procpath, exe_buf, sizeof(exe_buf) - 1);
          224  +		readlink_ret = readlink("/proc/self/exe", exe_buf, sizeof(exe_buf) - 1);
   223    225   
   224         -			if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) {
   225         -				exe_buf[readlink_ret] = '\0';
          226  +		if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) {
          227  +			exe_buf[readlink_ret] = '\0';
   226    228   
          229  +			SetExecName(interp, exe_buf);
          230  +
          231  +			return;
          232  +		}
          233  +	}
          234  +
          235  +	if (Tcl_GetNameOfExecutable() == NULL) {
          236  +		readlink_ret = readlink("/proc/curproc/file", exe_buf, sizeof(exe_buf) - 1);
          237  +
          238  +		if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) {
          239  +			exe_buf[readlink_ret] = '\0';
          240  +
          241  +			if (strcmp(exe_buf, "unknown") != 0) {
   227    242   				SetExecName(interp, exe_buf);
   228    243   
   229    244   				return;
   230    245   			}
   231    246   		}
   232    247   	}
   233    248   #endif /* HAVE_READLINK */