summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>1999-10-30 11:09:42 (GMT)
committerhobbs <hobbs@noemail.net>1999-10-30 11:09:42 (GMT)
commit19d37cea3398c5d08431fc9346d9dc7aa69a1eaa (patch)
treed7e89d4d2d749a55cd7c8e1c6461a6358f989c9e
parent728b709f10ce32b2a8786f9402b734b061c01b8b (diff)
downloadtcl-19d37cea3398c5d08431fc9346d9dc7aa69a1eaa.zip
tcl-19d37cea3398c5d08431fc9346d9dc7aa69a1eaa.tar.gz
tcl-19d37cea3398c5d08431fc9346d9dc7aa69a1eaa.tar.bz2
* unix/Makefile.in: purify has to use -best-effort to instrument
* unix/tclUnixPipe.c: fixed mem leak in TclpCreateProcess when doing alloc between vfork and execvp. * unix/tclUnixTest.c: fixed mem leak in findexecutable test command * unix/tclUnixNotfy.c: fixed event/io threading problems by making triggerPipe non-blocking FossilOrigin-Name: 07e490e23d760249c9356de7656ede4f6e882c6f
-rw-r--r--unix/Makefile.in14
-rw-r--r--unix/configure.in4
-rw-r--r--unix/tclUnixNotfy.c16
-rw-r--r--unix/tclUnixPipe.c49
-rw-r--r--unix/tclUnixTest.c5
5 files changed, 50 insertions, 38 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index f6facfb..155e3b1 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
-# RCS: @(#) $Id: Makefile.in,v 1.44.2.2 1999/10/02 01:09:54 hobbs Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.44.2.3 1999/10/30 11:09:43 hobbs Exp $
VERSION = @TCL_VERSION@
@@ -213,7 +213,7 @@ DLTEST_DIR = @TCL_SRC_DIR@/unix/dltest
# Must be absolute to so the corresponding tcltest's tcl_library is absolute.
TCL_BUILDTIME_LIBRARY= @TCL_SRC_DIR@/library
-#CC = purify @CC@
+#CC = purify -best-effort @CC@
CC = @CC@
#----------------------------------------------------------------
@@ -460,7 +460,7 @@ topDirName:
gendate:
yacc -l $(GENERIC_DIR)/tclGetDate.y
sed -e 's/yy/TclDate/g' -e '/^#include <values.h>/d' \
- -e 's/SCCSID/RCS: @(#) $$Id: Makefile.in,v 1.44.2.2 1999/10/02 01:09:54 hobbs Exp $$/' \
+ -e 's?SCCSID?RCS: @(#) $$Id: Makefile.in,v 1.44.2.3 1999/10/30 11:09:43 hobbs Exp $$?' \
-e '/#ifdef __STDC__/,/#endif/d' -e '/TclDateerrlab:/d' \
-e '/TclDatenewstate:/d' -e '/#pragma/d' \
-e '/#include <inttypes.h>/d' \
@@ -485,13 +485,13 @@ dltest/Makefile: $(DLTEST_DIR)/configure $(DLTEST_DIR)/Makefile.in tclConfig.sh
cd dltest; if test -f configure; then ./configure; else \
$(DLTEST_DIR)/configure; fi
-install: all install-binaries install-libraries install-doc
+install: install-binaries install-libraries install-doc
# Note: before running ranlib below, must cd to target directory because
# some ranlibs write to current directory, and this might not always be
# possible (e.g. if installing as root).
-install-binaries:
+install-binaries: binaries
@for i in $(LIB_INSTALL_DIR) $(BIN_INSTALL_DIR) ; \
do \
if [ ! -d $$i ] ; then \
@@ -521,7 +521,7 @@ install-binaries:
$(LIB_INSTALL_DIR)/$(TCL_STUB_LIB_FILE); \
fi
-install-libraries:
+install-libraries: libraries
@for i in $(INSTALL_ROOT)$(prefix)/lib $(INCLUDE_INSTALL_DIR) \
$(SCRIPT_INSTALL_DIR); \
do \
@@ -565,7 +565,7 @@ install-libraries:
$(INSTALL_DATA) $$i $(SCRIPT_INSTALL_DIR)/encoding; \
done;
-install-doc:
+install-doc: doc
@chmod +x $(UNIX_DIR)/mkLinks
@for i in $(MAN_INSTALL_DIR) $(MAN1_INSTALL_DIR) $(MAN3_INSTALL_DIR) $(MANN_INSTALL_DIR) ; \
do \
diff --git a/unix/configure.in b/unix/configure.in
index b372b68..e588cd3 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -2,12 +2,12 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tcl installation
dnl to configure the system for the local environment.
AC_INIT(../generic/tcl.h)
-# RCS: @(#) $Id: configure.in,v 1.48.2.1 1999/09/30 21:27:05 hobbs Exp $
+# RCS: @(#) $Id: configure.in,v 1.48.2.2 1999/10/30 11:09:44 hobbs Exp $
TCL_VERSION=8.2
TCL_MAJOR_VERSION=8
TCL_MINOR_VERSION=2
-TCL_PATCH_LEVEL=".1"
+TCL_PATCH_LEVEL=".2"
VERSION=${TCL_VERSION}
#------------------------------------------------------------------------
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 4053e4a..0600f81 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixNotfy.c,v 1.5 1999/07/02 06:05:34 welch Exp $
+ * RCS: @(#) $Id: tclUnixNotfy.c,v 1.5.4.1 1999/10/30 11:09:45 hobbs Exp $
*/
#include "tclInt.h"
@@ -719,15 +719,12 @@ Tcl_WaitForEvent(timePtr)
waitingListPtr = tsdPtr;
tsdPtr->onList = 1;
- Tcl_MutexUnlock(&notifierMutex);
write(triggerPipe, "", 1);
- Tcl_MutexLock(&notifierMutex);
}
memset((VOID *) tsdPtr->readyMasks, 0, 3*MASK_SIZE*sizeof(fd_mask));
if (!tsdPtr->eventReady) {
-
Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, timePtr);
}
tsdPtr->eventReady = 0;
@@ -750,10 +747,7 @@ Tcl_WaitForEvent(timePtr)
}
tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
tsdPtr->onList = 0;
- Tcl_MutexUnlock(&notifierMutex);
write(triggerPipe, "", 1);
- Tcl_MutexLock(&notifierMutex);
-
}
@@ -870,10 +864,18 @@ NotifierThreadProc(clientData)
if (fcntl(receivePipe, F_SETFL, status) < 0) {
panic("NotifierThreadProc: could not make receive pipe non blocking.");
}
+ status = fcntl(fds[1], F_GETFL);
+ status |= O_NONBLOCK;
+ if (fcntl(fds[1], F_SETFL, status) < 0) {
+ panic("NotifierThreadProc: could not make trigger pipe non blocking.");
+ }
#else
if (ioctl(receivePipe, (int) FIONBIO, &status) < 0) {
panic("NotifierThreadProc: could not make receive pipe non blocking.");
}
+ if (ioctl(fds[1], (int) FIONBIO, &status) < 0) {
+ panic("NotifierThreadProc: could not make trigger pipe non blocking.");
+ }
#endif
/*
diff --git a/unix/tclUnixPipe.c b/unix/tclUnixPipe.c
index b78715c..d2ce4a2 100644
--- a/unix/tclUnixPipe.c
+++ b/unix/tclUnixPipe.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixPipe.c,v 1.3 1999/04/16 00:48:05 stanton Exp $
+ * RCS: @(#) $Id: tclUnixPipe.c,v 1.3.6.1 1999/10/30 11:09:45 hobbs Exp $
*/
#include "tclInt.h"
@@ -333,7 +333,9 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
TclFile errPipeIn, errPipeOut;
int joinThisError, count, status, fd;
char errSpace[200 + TCL_INTEGER_SPACE];
- int pid;
+ Tcl_DString *dsArray;
+ char **newArgv;
+ int pid, i;
errPipeIn = NULL;
errPipeOut = NULL;
@@ -350,13 +352,20 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
goto error;
}
+ /*
+ * We need to allocate and convert this before the (v)fork
+ * so it is properly deallocated later
+ */
+ dsArray = (Tcl_DString *) ckalloc(argc * sizeof(Tcl_DString));
+ newArgv = (char **) ckalloc((argc+1) * sizeof(char *));
+ newArgv[argc] = NULL;
+ for (i = 0; i < argc; i++) {
+ newArgv[i] = Tcl_UtfToExternalDString(NULL, argv[i], -1, &dsArray[i]);
+ }
+
joinThisError = (errorFile == outputFile);
pid = vfork();
if (pid == 0) {
- Tcl_DString *dsArray;
- char *oldArgv0;
- int i;
-
fd = GetFd(errPipeOut);
/*
@@ -370,8 +379,7 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
((dup2(1,2) == -1) ||
(fcntl(2, F_SETFD, 0) != 0)))) {
sprintf(errSpace,
- "%dforked process couldn't set up input/output: ",
- errno);
+ "%dforked process couldn't set up input/output: ", errno);
write(fd, errSpace, (size_t) strlen(errSpace));
_exit(1);
}
@@ -381,22 +389,21 @@ TclpCreateProcess(interp, argc, argv, inputFile, outputFile, errorFile,
*/
RestoreSignals();
- for (i = 0; argv[i] != NULL; i++) {
- /*
- * How many arguments?
- */
- }
- oldArgv0 = argv[0];
- dsArray = (Tcl_DString *) ckalloc(i * sizeof(Tcl_DString));
- for (i = 0; argv[i] != NULL; i++) {
- argv[i] = Tcl_UtfToExternalDString(NULL, argv[i], -1, &dsArray[i]);
- }
- execvp(argv[0], argv); /* INTL: Native. */
- sprintf(errSpace, "%dcouldn't execute \"%.150s\": ", errno,
- oldArgv0);
+ execvp(newArgv[0], newArgv); /* INTL: Native. */
+ sprintf(errSpace, "%dcouldn't execute \"%.150s\": ", errno, argv[0]);
write(fd, errSpace, (size_t) strlen(errSpace));
_exit(1);
}
+
+ /*
+ * Free the mem we used for the fork
+ */
+ for (i = 0; i < argc; i++) {
+ Tcl_DStringFree(&dsArray[i]);
+ }
+ ckfree((char *) dsArray);
+ ckfree((char *) newArgv);
+
if (pid == -1) {
Tcl_AppendResult(interp, "couldn't fork child process: ",
Tcl_PosixError(interp), (char *) NULL);
diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c
index 7c7559b..8ac0b9b 100644
--- a/unix/tclUnixTest.c
+++ b/unix/tclUnixTest.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixTest.c,v 1.10 1999/04/16 00:48:05 stanton Exp $
+ * RCS: @(#) $Id: tclUnixTest.c,v 1.10.6.1 1999/10/30 11:09:45 hobbs Exp $
*/
#include "tclInt.h"
@@ -465,6 +465,9 @@ TestfindexecutableCmd(clientData, interp, argc, argv)
Tcl_SetResult(interp, tclExecutableName, TCL_VOLATILE);
ckfree(tclExecutableName);
}
+ if (tclNativeExecutableName != NULL) {
+ ckfree(tclNativeExecutableName);
+ }
tclExecutableName = oldName;
tclNativeExecutableName = oldNativeName;