Tcl Source Code

Changes On Branch bug-c6897e6e6a
Login

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

Changes In Branch bug-c6897e6e6a Excluding Merge-Ins

This is equivalent to a diff from a89e327cbb to 2492fd146e

2024-05-22
10:22
cherry-pick [659ca0ae8da43a1e] for 8.6: don't need to invoke it in case if oPtr->selfCls is NULL check-in: 3ebb66feb1 user: sebres tags: core-8-6-branch
09:24
Merge 8.6. Fix TCL_NO_DEPRECATED build check-in: dbeb93773b user: jan.nijtmans tags: core-8-branch
09:11
Merge-mark Leaf check-in: 2492fd146e user: jan.nijtmans tags: bug-c6897e6e6a
09:09
Spacing/code cleanup, backported from 8.7 20:19:30 [4c1393b596] *CURRENT* "TCL_TOMMATH" is not used ... check-in: a89e327cbb user: jan.nijtmans tags: core-8-6-branch
09:04
Proposed fix for [c6897e6e6a]: select notifier crashes/misbehaves on fd >= FD_SETSIZE check-in: fe9f18909d user: jan.nijtmans tags: bug-c6897e6e6a
2024-05-21
20:19
"TCL_TOMMATH" is not used anywhere check-in: 4c1393b596 user: jan.nijtmans tags: core-8-6-branch

Changes to unix/tclUnixPipe.c.

151
152
153
154
155
156
157











158
159
160
161
162
163
164
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175







+
+
+
+
+
+
+
+
+
+
+







    int fd;
    const char *native;
    Tcl_DString ds;

    native = Tcl_UtfToExternalDString(NULL, fname, -1, &ds);
    fd = TclOSopen(native, mode, 0666);			/* INTL: Native. */
    Tcl_DStringFree(&ds);

    /*
     * Ticket [c6897e6e6a].
     */

    if (fd >= FD_SETSIZE) {
	close(fd);
	fd = -1;
	errno = EMFILE;
    }

    if (fd != -1) {
	fcntl(fd, F_SETFD, FD_CLOEXEC);

	/*
	 * If the file is being opened for writing, seek to the end so we can
	 * append to any data already in the file.
	 */
316
317
318
319
320
321
322










323
324
325
326
327
328
329
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350







+
+
+
+
+
+
+
+
+
+







				 * side of pipe. */
{
    int pipeIds[2];

    if (pipe(pipeIds) != 0) {
	return 0;
    }

    /*
     * Ticket [c6897e6e6a].
     */

    if (pipeIds[0] >= FD_SETSIZE || pipeIds[1] >= FD_SETSIZE) {
	close(pipeIds[0]);
	close(pipeIds[1]);
	return 0;
    }

    fcntl(pipeIds[0], F_SETFD, FD_CLOEXEC);
    fcntl(pipeIds[1], F_SETFD, FD_CLOEXEC);

    *readPipe = MakeFile(pipeIds[0]);
    *writePipe = MakeFile(pipeIds[1]);
    return 1;
892
893
894
895
896
897
898
899

900
901















902
903
904
905
906
907
908
913
914
915
916
917
918
919

920
921

922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943







-
+

-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







int
Tcl_CreatePipe(
    Tcl_Interp *interp,		/* Errors returned in result. */
    Tcl_Channel *rchan,		/* Returned read side. */
    Tcl_Channel *wchan,		/* Returned write side. */
    int flags)			/* Reserved for future use. */
{
    int fileNums[2];
    int ret, fileNums[2];

    if (pipe(fileNums) < 0) {
    ret = pipe(fileNums);
    if (ret >= 0) {

	/*
	 * Ticket [c6897e6e6a].
	 */

	if (fileNums[0] >= FD_SETSIZE || fileNums[1] >= FD_SETSIZE) {
	    close(fileNums[0]);
	    close(fileNums[1]);
	    errno = EMFILE;
	    ret = -1;
	}
    }
    if (ret < 0) {
	Tcl_SetObjResult(interp, Tcl_ObjPrintf("pipe creation failed: %s",
		Tcl_PosixError(interp)));
	return TCL_ERROR;
    }

    fcntl(fileNums[0], F_SETFD, FD_CLOEXEC);
    fcntl(fileNums[1], F_SETFD, FD_CLOEXEC);