Index: kitsh/buildsrc/kitsh-0.0/configure.ac ================================================================== --- kitsh/buildsrc/kitsh-0.0/configure.ac +++ kitsh/buildsrc/kitsh-0.0/configure.ac @@ -38,10 +38,13 @@ dnl Determine if we have "Tcl_SetStartupScript" (8.6.x) or "TclSetStartupScriptPath" (8.4.x) AC_CHECK_FUNCS(Tcl_SetStartupScript TclSetStartupScriptPath) dnl Check for the ability to get the current system encoding AC_CHECK_FUNCS(Tcl_GetEncodingNameFromEnvironment Tcl_SetSystemEncoding) LIBS="${SAVE_LIBS}" + +dnl Check for optional system calls +AC_CHECK_FUNCS(readlink) dnl Find zlib AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib], [directory containing zlib]), [ CPPFLAGS="${CPPFLAGS} -I${with_zlib}/include -I${with_zlib}" CFLAGS="${CFLAGS} -I${with_zlib}/include -I${with_zlib}" Index: kitsh/buildsrc/kitsh-0.0/kitInit.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/kitInit.c +++ kitsh/buildsrc/kitsh-0.0/kitInit.c @@ -159,20 +159,46 @@ /* SetExecName -- Hack to get around Tcl bug 1224888. */ void SetExecName(Tcl_Interp *interp) { +#if defined(HAVE_READLINK) + if (tclExecutableName == NULL) { + ssize_t readlink_ret; + char procpath[PATH_MAX + 1]; + char exe_buf[PATH_MAX + 1]; + int snprintf_ret; + + snprintf_ret = snprintf(procpath, sizeof(procpath), "/proc/%lu/exe", (unsigned long) getpid()); + if (snprintf_ret < sizeof(procpath)) { + readlink_ret = readlink(procpath, exe_buf, sizeof(exe_buf) - 1); + + if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) { + exe_buf[readlink_ret] = '\0'; + + tclExecutableName = strdup(exe_buf); + + return; + } + } + } +#endif + if (tclExecutableName == NULL) { int len = 0; Tcl_Obj *execNameObj; Tcl_Obj *lobjv[1]; lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY); execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv); tclExecutableName = strdup(Tcl_GetStringFromObj(execNameObj, &len)); + + return; } + + return; } int TclKit_AppInit(Tcl_Interp *interp) { #ifdef TCLKIT_CAN_SET_ENCODING Tcl_DString encodingName;